Ad
  • Custom User Avatar

    @natan True, but the whole point was about me beeing confused. It just took B1t's message to make me realize the problem. Thx anyway :)

  • Custom User Avatar

    literally the first thing I told you

  • Custom User Avatar

    Thanks B1ts! Finally a good information that solved the misunderstanding!

  • 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 second one. Thats what I mean. It should not be this way. Anyway...thanks for trying

  • Custom User Avatar

    read my first reply in this thread

  • Custom User Avatar

    I can't remember for sure but I was doing something like this:

    myvar = inputvar

    doing stuff with myvar and return it

    feedback: You are not allowed to mutate...:(

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

  • 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

    When we talk about the original array, are we referring to the original variable itself, or just the order of the elements? At first, I tried to modify the original variable directly. Then, I made a copy of the array and tried to modify the copy, but that didn’t work either. I saw other solutions where people were just swapping elements within the array, which suggests they must have been modifying the original 'order of elements'... It's confusing, isn’t it?

  • 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

    Hobovsky, no offense, but did you actually read what I just said? :) I did not try to manipulate the original array. I created a new one, still could not manipulate it

  • 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

    As a Kyu7 task, it should highlight this kind of 'rabbit hole' to help prevent people from falling too deeply into it.

  • Custom User Avatar

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

  • Loading more items...