Ad
  • Custom User Avatar

    It's very difficult, and in many languages not really possible to be done reliably. Kata which attempt such restrictions usually end up being very poor at enforcing them. The best approach is to avoid such requirements. There is no good, reliable way to test against them.

  • Default User Avatar

    Thanks for your post and good luck with C:-)

  • Default User Avatar

    Morality of the story: don't post issues too fast:-) It tooks me time to examine your solution:-(

  • Default User Avatar

    but if the st passed is "Lagon,Lily", and my function simply processes the given arguments, how could "Elizabeth" even be a possible result of the function

    Print your array "names" before your return. When I do that in your solution I get "Lily", "Elizabeth" and your return is ofc Elizabeth...

    it returns "Lagon" on my own system when given the exact same arguments

    Try on your system not only that test but several tests in a row and you will see. Or add this test

    {
        char* st = "Lagon,Lily";
        int we[2] = {1, 5};
        dotest(st, we, 2, 2, "Lagon");
    }
    

    at the end of the "Sample Tests". Your answer will anew be Elizabeth.

  • Default User Avatar

    Expected Lagon, but got Elizabeth.

    You returned Elizabeth.

    I think there may be an issue with the testing.

    As far as I know there is no problem in the testing since 67 guys passed the C kata. Moreover I tried a few solution and all worked fine.

    Update:
    You should read https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution.

  • Custom User Avatar

    I just solved C version and after a bit of a hassle with edge cases, I got it to pass without problem. Make sure to correctly handle edge cases (leading zeros in input, overflow), recreate and debug failing cases locally, and you should be able to make it work.

    I do not know if having no free was a part of your debugging or maybe intentional, but you probably cannot solve the kata without mallocing and eventually freeing a helper buffer, so "i have no free" is actually a symptom of a bug. Additionally, it says "... or corruption", and double free is not only reason for the error. It can be also a result of out-of-bounds writes (which I experienced).

  • Custom User Avatar

    You are the real MVP.

  • Default User Avatar

    Thanks for the hint.

  • Custom User Avatar

    I do think the author do this on purpose to simulate a unclear requirement problem faced everyday by programmers.

    And if you points it out, he will pull the ole "xxx numbers of people passed the kata" crap. Boils anyones blood really.

    I cant do most of his kata but I dont hate him.