7 kyu
Linked Lists - Move Node
705 of 1,774JDeBolt
Loading description...
Linked Lists
Data Structures
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
CoffeeScript translation (language agnostic description)
Maybe I'm missing something but I think the Python version could return a tuple of two nodes instead of the weird context thing.
I agree but this kata is old and has been solved many times so it won't be done.
I'm passing all the tests but the last subtest of empty destination, which I am also not able to figure what is it actually asserting as the failure specifies only
While no data value equals 0, nor even there is a list of length one. Below ther is a log of my returned context object
My bad. I've had a foulty modification of the Node constructor.
Ruby :
"You should throw an error when the source list is empty. "
Ok, there is code there to do it, but it always passes.
This isn't an issue, but maybe the description could be clarified as you don't need to throw an exception, the code just has to generate one naturally.
This comment has been hidden.
Fixed.
[Python, Ruby, Swift] Needs random test cases
added Java translation
For me not enough explanation.
I get an error in this test: move_node([1, 2, 3, None], None)
In my solution its equal Context([2, 3, None], Node(1)) and all fine, but i get an error: <__main__.Node object at 0x7fb1cde74ba8> should equal None
I check: move_node([1, 2, 3, None], None).source move_node([1, 2, 3, None], None).dest.data move_node([1, 2, 3, None], None).dest.next all fine and equal to Context([2, 3, None], Node(1))
Where my error?
For those having trouble, refer to the LinkedLists documentation provided. It helped me understand the task at hand since there was no explanation anywhere else. The missing functions and everything are in the pdf.
Here is the link for it: http://cslibrary.stanford.edu/103/LinkedListBasics.pdf
I don't really understand linked lists nor do I understand the test cases as they are calling functions not in the code. I've tried using array methods a they are not defined can you point me to some info about this subject I will study and come back?
Thanks
This comment has been hidden.
Got this kata randomly so I didn't initially realize the linked list methods were defined in other katas, would be helpful to call that out. Also would be good to clarify the code given is pseudocode.
CoffeScript and Ruby translations kumited.
Missing sample tests for ruby.