Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
I got the tests to pass, but the "attempt" tests are too difficult to debug at 6k loop size. Anyone have suggestions or tips?
unable to use ruby language hashes in solution.
gives
h={}
You're right, I missed the note. Thank you very much
It looks that you fail a test with a single node pointing to itself.
Also please note that you should not modify existing nodes.
node.visited = true
is not something you need, and Id have to check if tests verify whether nodes are not modified. Tests should fail when you change nodes.This comment is hidden because it contains spoiler information about the solution
It's impossible to answer your "question" since you don't make it clear what you don't understand - for example, here is the first paragraph from Wikipedia article about linked lists:
In computer science, a linked list is a linear collection of data elements whose order is not given by their physical placement in memory. Instead, each element points to the next. It is a data structure consisting of a collection of nodes which together represent a sequence. In its most basic form, each node contains: data, and a reference (in other words, a link) to the next node in the sequence.
Do you understand all of the words/concepts in this small paragraph? If not, then you need to read more.
If you do understand all the concepts, then let me try to rephrase this kata:
Referring to the illustration, if you start at node A and only use the
node.next
attribute, you will visit - in order - B then C then 1 then 2 then 3 .... then 10 then 11 then 12 then 1 aha!! we have reached a node, 1, that we have already visited before. In other words, our linked list contains a loop. The loop is of size 12 since it begins at node #1 and goes all the way to node #12 before returning to node #1.Can you figure out a way to "measure" the size of such a loop (in the case, size = 12) in a general linked list, using only the "vist next node" operations (i.e.
node.next
in this kata) ?Really not easy to understand what's the problem. Could you plz explain more, for better understand.
This comment is hidden because it contains spoiler information about the solution
akar-0 was trying to help you and he just wrote a cordial message and behaved in a civilised way as should anyone in comment sections.
Me give linked list. You find how big loop. You use node.next attribute only.
No need to write to me arrogantly. Write only to the point. You need to play Sherlock Holmes somewhere else please.
The task is explained in the description. If you don't understand it, you are most likely not able to solve it at the moment. I advice you to get more familiarized with linked lists solving some amount of easier katas related with this data structure.
I didn't understand, what exact problem I have to solve?
The message is bad and tests need to be fixed a bit to make messages better.
But still your solution is not what is expected. You are not supposed to modify nodes. Your assignment
node.number = count
should not be there.I will try to fix tests to make messages clearer.
This comment is hidden because it contains spoiler information about the solution
Loading more items...