Ad
  • Custom User Avatar

    It might help, but notice that your soltion still crashes in one of ~five runs. Apparently, mutating the array only emphasized some other bug sitting somewhere there.

  • Custom User Avatar

    Additionally, in some cases your call to is_pair(*start, *(start + 1)) seems to read past the end of the arr.

  • Custom User Avatar

    The cause of your problem is the fact that your code mutates arr, and the changes you make to it destroy the data which is later used by tests to verify your result. Unfortunately, for some reason beyond my understanding, the solution function accepts the input as a non-const reference, and any mutation turns out to be destructive. You can resolve your issue by either making a copy of arr in your solution, or changing the function signature to accept arr by value or by const reference.

    I will fix the setup of the challenge and change the function signature some time soon, but I cannot give any ETA for that.

  • Custom User Avatar

    But isn't it more logical to cancel out everything even if it's not directly opposite? If 'NORTH, WEST, SOUTH, EAST' brings you to the same spot, why does tha kata request to not remove anything (because it's not directly opposite)? I'm just curious, as if I was to build a similar function in the future, I would do it my way

  • Custom User Avatar

    Point # 3 doesn't make sense, logically & practically.

    It makes perfect sense, if you don't start making up your own rules. You need to follow the rules of the kata, not what you believe. "distance", as you desribe it, is irrelevant here.

  • Custom User Avatar

    What update would you suggest? Because the description tells you MULTIPLE times about this quality to the kata task.

    1. Going to one direction and coming back the opposite direction right away is a needless effort.

    2. You can immediately see that going "NORTH" and immediately "SOUTH" is not reasonable, better stay to the same place!

    3. "NORTH" and "WEST", "WEST" and "SOUTH", "SOUTH" and "EAST" are not directly opposite of each other and can't (be reduced).

    And for that matter very test case we're talking about is literally discussed directly in the Notes section.

  • Custom User Avatar

    You misunderstand the task.

    The correct answer to the Fixed Test you showed is {"NORTH","WEST","SOUTH","EAST"}, because there are no consecutive opposite directions to reduce.

  • Custom User Avatar

    The "sample tests" block of the "Attempt" contain more assertions than those of the "Test", this is why you pass the latter but not the former.
    Your code throws an error when ending is longer than str.
    Please, do not raise issues to ask for help; a bug in your code is not a kata issue; you can ask questions instead. When you post your code, don't forget to add the spoiler flag and to format with Markdown

  • Custom User Avatar

    Sorry, no error in the tests. Kata passed by 85,171 people...