Ad
  • Custom User Avatar

    literally the first thing I told you

  • Custom User Avatar

    No offense but yes, I read your comments, and exactly from your comments i figured out that most probably you did what you think was cloning, but really was not ;)

  • Custom User Avatar

    so how can other people swap stuff arround with cloned arrays?

    Because they cloned it? It doesn't affect the original array. myvar = inputvar doesn't clone anything, it's just another variable name pointing to the same input array.

  • Custom User Avatar

    read my first reply in this thread

  • Custom User Avatar

    this is what's going on:

    xs = [3, 2, 1]
    solution(xs)
    print(xs)  # should still say [3, 2, 1]
    
  • Custom User Avatar

    You DID mutate the original array. That is exactly what that test measures. It looks at the array before and after. That's also why it doesn't want you to mutate it. The caller doesn't want their stuff to be scrambled. Your method should look at it but not touch it.

    The more general applicable advice here, I think, is that you should ensure that you can observe and reproduce whatever it is you are trying to fix. So that you KNOW it's happening. Not just for kata, but for any bug, or really anything that you're trying to change. Don't be blind, look at the thing you're doing.

  • Custom User Avatar

    It already says it in the description: "should return a new array ", and "it should not mutate the input array", etc.

  • Custom User Avatar

    sounds to me like you created a new variable instead of copying the array

  • Custom User Avatar

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

  • Custom User Avatar

    Absolutely agree, more deserving of 6 kyu minimum