Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Maybe use 'A' character value syntax instead of raw ASCII values to be more readable?

  • Custom User Avatar

    because the input is passed by reference, it's not a copy of it. So if you modify it inside your function, any other function outside that sees the exact same instance of this object will see the modifications too (even if not expected).

  • Custom User Avatar

    It changes exactly as you change the input. Think about it like it's the same instance of an object.

  • Custom User Avatar

    But if I mutate the input in the function how does it change it outside the function?

  • Custom User Avatar

    I'll tell you why that matters. The tests are written that way. They allow your function to run first, and then they do solve the problem on the data themselves. If you mutate the input, their solver takes invalid input, thus gives invalid result. It's a bad test, becacuse it's easy to make it pass every time without solving the problem, but hey! We've got what we've got.

  • Custom User Avatar

    I don't get why that matters though (and I tried that, the same thing happened though)
    edit: I got my solution to work with some really weird workarounds, but it's obviously not supposed to be done like this.

  • Custom User Avatar

    Easy: don't mutate the input. ;p

  • Custom User Avatar

    I'm having the same problem, did you solve it and if so, how?

  • Custom User Avatar

    I did. And probably that's the reason.
    I did it on purpose, knowing it's a bad thing, but that never was a problem so far. I guess I'm learning on my mistakes.
    You are right.

  • Custom User Avatar

    Did you mutate the input?

  • Custom User Avatar

    I've got a weird error with random tests. For all of them it wants me to return just the last step, and not the whole path. Example:
    Expected: ['R30'], instead got: ['L7', 'D1', 'R9', 'D1', 'L25', 'D1', 'R13', 'D1', 'L21', 'D1', 'R3', 'D1', 'R22', 'D1', 'R4', 'D1', 'L10', 'D1', 'R15', 'D1', 'L4', 'D1', 'L5', 'D1', 'L21', 'D1', 'R24', 'D1', 'L14', 'D1', 'R19', 'D1', 'R4', 'D1', 'L27', 'D1', 'L13', 'D1', 'R10', 'D1', 'R1', 'D1', 'R29', 'D1', 'L7', 'D1', 'L1', 'D1', 'L17', 'D1', 'R6', 'D1', 'R5', 'D1', 'R4', 'D1', 'L13', 'D1', 'L4', 'D1', 'L5', 'D1', 'L10', 'D1', 'R20', 'D1', 'R23', 'D1', 'L33', 'D1', 'R17', 'D1', 'L4', 'D1', 'L5', 'D1', 'R4', 'D1', 'R18', 'D1', 'L24', 'D1', 'R26', 'D1', 'L18', 'D1', 'L6', 'D1', 'L17', 'D1', 'R31', 'D1', 'R11', 'D1', 'L40', 'D1', 'R37', 'D1', 'L17', 'D1', 'R16', 'D1', 'R3', 'D1', 'L8', 'D1', 'R7', 'D1', 'L28', 'D1', 'R8', 'D1', 'L13', 'D1', 'L8', 'D1', 'R27', 'D1', 'L23', 'D1', 'R9', 'D1', 'L7', 'D1', 'R35', 'D1', 'L28', 'D1', 'L5', 'D1', 'R16', 'D1', 'L9', 'D1', 'R14', 'D1', 'R8', 'D1', 'L27', 'D1', 'R7', 'D1', 'R19', 'D1', 'L14', 'D1', 'R9', 'D1', 'R4', 'D1', 'L8', 'D1', 'R11', 'D1', 'L7', 'D1', 'L6', 'D1', 'L7', 'D1', 'L4', 'D1', 'R28', 'D1', 'L6', 'D1', 'L35', 'D1', 'R17', 'D1', 'L20', 'D1', 'R25', 'D1', 'R21', 'D1', 'L15', 'D1', 'L6', 'D1', 'L9', 'D1', 'R25', 'D1', 'L5', 'D1', 'L3', 'D1', 'L9', 'D1', 'L20', 'D1', 'L4', 'D1', 'R13', 'D1', 'L12', 'D1', 'R15', 'D1', 'R27', 'D1', 'L9', 'D1', 'L19', 'D1', 'R31', 'D1', 'L16', 'D1', 'L21', 'D1', 'R27', 'D1', 'L31', 'D1', 'L1', 'D1', 'R18', 'D1', 'L6', 'D1', 'R30']