6 kyu

Plenty of Fish in the Pond

47 of 1,281adrian.eyre
Description
Loading description...
Fundamentals
  • Please sign in or sign up to leave a comment.
  • marjan Avatar

    Can anyone explain me:How we get for "111111111111111111112222222222" the length of the fish is 5? I've found it 1111 (2) 2222 (3) 111111111111 (4) 1111222222 (5)

  • Monon747 Avatar

    This comment has been hidden.

  • ah2023 Avatar

    C#: How can the expected fish size be 13 if the fish size ranges from 0-9?

    Testsing for '2377850450199216028943563875738515541737295533926856280293197429940060020'
    
    Test Failed
      Assert.That(game1.fish(fs1), Is.EqualTo(result))
      Expected: 13
      But was:  7
    

    Can anybody help me?

  • Dian Li Blake Avatar

    I have finished, but I still can't understand the question. It feels like the description is a bit lengthy.

  • ejini战神 Avatar

    C#: method name should be PascalCase (Please refer to implementation of backward compatibility here )

  • Fbasham Avatar

    The rust initial code is wrong/misleading. The intial code setup has:

    fn fish(shoal: String) -> i32 {
        // your code
        todo!()
    }
    

    but it should be:

    fn fish(shoal: &String) -> u32 {
        // your code
        todo!()
    }
    
  • nomennescio Avatar

    Description does not allow a fish to grow beyond size 7, because only for a fish of size 6 it's specified how many fish to eat to grow to size 7. However, nothing is specifief for fishes of size 7, hence it could be infinite for all we know, i.e. impossible to grow. But the tests show that fishes can reach sizes beyond 7.

    Adapt the description.

  • laurelis24 Avatar

    If only i knew math. This actually doesnt look hard at first, but can be a bit tricky.

  • Chibranche Avatar

    When attempting to submit, I sometimes get expected values higher than maximum size possible (JS) :

    Should return '10' - Expected: 10, instead got: 7 Log Testing for '9518416642975095'

  • bsuman@codewars Avatar

    Hello, interesting task but I would suggest writing explicitly that in case of overeating ( eating total sum of 14 instead of total sum of 12 on fish size 3), the extra eaten size will be considered for the next size to grow. i.e. amount of fish eaten to be size 4 is not 16 rather is 14 as in the previous step overeating done by 2

  • marjan Avatar

    How does we treat this string 111111111111111111112222222222 so the size is 5?

  • erick_codewars Avatar

    This comment has been hidden.

  • akar-0 Avatar

    C tests return plenty of warnings:

    setup.c:8:22: warning: implicitly declaring library function 'calloc' with type 'void *(unsigned long, unsigned long)' [-Wimplicit-function-declaration] char shoal_copy = calloc(str_len, sizeof(char)); ^ setup.c:8:22: note: include the header <stdlib.h> or explicitly provide a declaration for 'calloc' setup.c:9:3: warning: implicitly declaring library function 'strcpy' with type 'char *(char *, const char *)' [-Wimplicit-function-declaration] strcpy(shoal_copy, shoal); ^ setup.c:9:3: note: include the header <string.h> or explicitly provide a declaration for 'strcpy' setup.c:10:3: warning: implicit declaration of function 'qsort' is invalid in C99 [-Wimplicit-function-declaration] qsort(shoal_copy, str_len, sizeof(char), __preloaded_char_cmp); ^ setup.c:24:3: warning: implicit declaration of function 'free' is invalid in C99 [-Wimplicit-function-declaration] free(shoal_copy); ^ etc.

  • heckadactyl Avatar

    Awesome Kata. Thanks again for all your hard work.

  • raveneer Avatar

    descriptions table contains fish size only to 6.

    test case contains to 9.

    we can expect fish size up fomula. but that's cofusing.

  • user2992854 Avatar

    I couldn't find the solution for this exercise, so I decided to unlock it to see the solution of the other users. Therefore I could figured why I wasn't able to pass the test suite: the amount of fishes needed to grow it doesn't have to be EXACTLY the same of the chart but it can be more (i.e. to grow to size 3 i can eat 9 fishes (1 size) and not exactly 8 fishes). At least for me it is not so obvious so I suggest to specify it on details.

    Congrats to author, all yours exercises help me and stimulate me to improve my coding skills in this phase where I am newbie yet.

  • jazfunk Avatar

    This comment has been hidden.

  • Darkdenied Avatar

    I'm testing in VB. In my code give me these errors, but they're can't be correct. Food is 180 and for fish 11 it need 220, so its impossible to be fish 25 ( and i've sorted the string from 0 to 9 ). Testing for '314592418182547723040447879492607488233699817548247311587661201647516859044163023125538599156139716903238827632364817611991660290534702098670085679222110400156853710765281904180699006732420183172736590394011532945774698723509882234410870161189713849703876689423839753580353' Test Failed Expected: 25 But was: 10

    Please Fix the test errors.

  • snschroeder Avatar

    It seems like something weird is going on with a few of the random test cases.

    For instances, I received '4677038' as my shoal.

    Since our fish starts as size 1, there is nothing to eat. However, the test said it expected size 7 as the final result.

    Other examples I saw: '08995899224880' - expected 7 '784181449' - expected 4

    Am I missing something or is there an error?

  • dlcoe Avatar

    This comment has been hidden.

  • clcraig Avatar

    @WojciechBuczek, the Criterion test suite that codewars uses for C and NASM testing has some major drawbacks and limitations regarding output. The cr_assert_* functions' default output is useless for debugging. It prints the underlying C code, not the actual return and expected values. Also, anything sent to stdout gets interwoven with the test suite's output.

    To fix the first issue, I use a wrapper function for each test rather than calling the cr_assert_* function directly. This wrapper takes the test input and expected value(s), calls the user function, explicitly does all the return value checking, manages memory where applicable, and finally calls the cr_assert_* with an explicit error message stating what's wrong.

    To compensate for the second issue, I only call the cr_assert_* when I know a failure will happen, allowing passes to fall through unreported. Then at the end of each Test() {} block I flush stdout and finish with cr_assert(true);. This last step ensures that passed test blocks will be counted as such.

    If you want some examples of this approach, then take a look at my C translations of these kata. https://www.codewars.com/kata/odd-even-string-sort/c https://www.codewars.com/kata/smooth-numbers/c https://www.codewars.com/kata/cogs/c

  • clcraig Avatar

    @WojciechBuczek, your assertion statements in both C & C++ are backwards. The expected value should come second. For example, if the correct result is 4 but the user returns 1, you'll see this in the C++ output.

    Expected: equal to 1
    Actual: 4
    

    This is going to cause headaches, damage laptops, enrich drug dealers, and destroy marriages. :-S

    A C++ test statement like this Assert::That(4, Equals(fish("111122223333"))); should be this Assert::That(fish("111122223333"), Equals(4));.

    A C test statement like this cr_assert_eq(4, fish(shoal_3, strlen(shoal_3))); should be this cr_assert_eq(fish(shoal_3, strlen(shoal_3)), 4);.

  • wthit56 Avatar

    I'd strongly suggest making it clearer that you don't just go through the list of fish once, but just go around eating as many fish as you can. While you don't specify looping through them once, I think a lot of programmers will make that assumption.

  • WojciechBuczek Avatar
  • JohanWiltink Avatar
  • WojciechBuczek Avatar

    This comment has been hidden.

  • theCaseyLeggett Avatar

    This one took me a while to puzzle out but it was a good one! I've really enjoyed your katas, they are presented very well and are always interesting. Keep up the good work!

  • skeletoo Avatar

    This comment has been hidden.

  • Blind4Basics Avatar

    Hi,

    I had the same problem than myjinxin2015 (see below). I think you should update the description to make clearer that the order in the string isn't relevant or provide another example with an unordered shoal string (the kata is only 6kyu ;) )

    Cheers,

    B4B

  • myjinxin2015 Avatar

    The last example testcase:

    fish:1 5 1 1 2 8 2 4 1 2 1 2 1 9 2 1 1 3 7 2 2 3  2 1 3 3 1
    exp :1   2 3         4 2 3 5 6   8 1 2 5   7 9 12 2 3 6 9 10
    size:1               2           3             4              where is 5?
    

    Why your fish so fat? ;-)

  • Voile Avatar
    Test.expect(fish("111122223333")==4, "Should return '4'")
    Test.expect(fish("111111111111")==3, "Should return '3'")
    

    ???

    Please explain what happens when you eat a fish smaller than your size.

  • clydiscope Avatar

    I'm having trouble with passing the last test case. I'm counting through the shaol, and personally, I expect the maximum to be 4 instead of 5.

  • adrian.eyre Avatar

    Plenty of Fish in the Pond ready for appoval if any moderators are free please :-)

  • NikosAthens Avatar

    Nice Kata! I liked the formulation of the problem. Too many ideas for similar katas can grow from this one. Feel free to check my Katas too they are still all on Beta!

  • K1ngMX Avatar

    i really like this kata. Sounds easy, but has some interesting concepts you need to understand. Nice one :) !