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

  • Each time I create a chain list with a loop and you a to find the loop's size

    1. I show you the full Node class, so why do you complain about it ? You identify the node by the object id, it is enough.
    2. I overwrite the Hash methods because you should no use them, if you write your own hash-like class YOU'RE DOINT IT WRONG.

    "Thanks to shadchnev, I broke all of the methods from the Hash class."

    1. You don't need a method create_chain that's why codewars is here just type your code in the browser and run the tests.
    2. OBJECTIVE : Your objective is to determine the length of the loop. -> How can it be more clearer ?
    3. Use the function #next to get the following node. -> means do not touch the nodes and use the object id to compare the node.
    4. The code is runned on their servers so the timeout is due to your connection or bad solution
  • Can't see your solution (I improved the test cases)

  • Don't see your solution . . .

  • this is codewars not codekindergarten ;-)

    1. thanks
    2. done
    3. it can be unfrozen, no ?
  • I am not very good with specific points in javascript, main idea is not to change any nodes. Just to use some locals variables.

  • You should no touch the node, just use local variables inside the method

  • I tried your solution on compileonline.com and got a NoMethodError, I don't know why it works there. Put begin rescue and it solved the problem

  • You have a timeout ?

  • I run your code and indeed it should work when there is no tail. But all the test cases (except the first) have a tail and a loop so your code won't work which is normal.
    What it returns is the size of the tail + loop not the loop only.

  • As i said in the description there is always a loop so the object_id should not increment infinitely.
    I try to print the object_id as you did and i didn't see any problem with the id.
    Maybe try to compare the object itself.

  • Perfect, your changes made me pass all the tests without changing anything !!!

  • Ok i think i understand the problem, my code change the value of your wishlist, so when you give me your wishlist as a parameter in the test 3 there is only 2 value in the array.

    Got 2 and 2 when i print the variable of your wishlist and presents array for the third test while i got 3 and 2 for the first and second test
    When I remove my code I got 3 and 2 for the third test instead of 2 and 2.

    I hope you you understand me

    p wishlist.clone.size
    p presents.clone.size 
  • Loading more items...