Ad
  • Default User Avatar

    your logic is wrong, comparing the sums of ascii codes will lead to false positives, e.g. your code returns true for "ac", "bb".

    Other issues:

    • you cast const away in your loop to convert the strings to uppercase --> don't do that; not only is it bad practice but it will crash when the strings are immutable
    • this same loop also assumes that the strings are the same length and that they have lowercase letters at the same indices... you should iterate on them separately, after making a copy first
  • Default User Avatar

    not sure for C but the logic is: check if your summ divides with no remainder first, if yes then just return summ/n C:

  • Custom User Avatar

    No worries :) be aware of the difference between a null string and and an empty one.

  • Custom User Avatar

    What happens in your solution if the string is empty?

  • Default User Avatar

    op solved the kata

  • Custom User Avatar

    OP solved it, closing

  • Custom User Avatar
  • Custom User Avatar
  • Default User Avatar

    For the 1st sample test, your code returns true. However, the input

    test("hello_world", false);
    

    includes an underscore, so your code should have returned false.

  • Default User Avatar

    Oy. nevermind, I was looking at your solution thinking it was your working draft but it apparently works and I'm obviously wrong about things. My apologies

  • Default User Avatar

    You're only changing even in the event that the first two array elements are the same. I'm betting those will be the tests that do pass. Otherwise even == 0 so when you check arr[i] against it inside the loop, it does nothing good for you.

  • Custom User Avatar
  • Default User Avatar

    have you figure it out? It was quite challenging and satisfying to complete this task.

  • Default User Avatar

    added better messages

  • Custom User Avatar

    It always helps to mention your language. And yes, users who completed the kata in the same langiage can see your most recently attempted code.

    Again, you sohuld try and run your solution locally, in your IDE, and call it twice in one test run. There's more than one problem with it currently, but the main issue is the while loop which is not really necessary, and causes the problem you see.
    Another issue is returning a statically allocated buffer, what is almost always wrong. This kata wants you to return a malloced, freeable buffer.

  • Loading more items...