6 kyu
Parse a linked list from a string
116 of 2,297donaldsebleung
Loading description...
Linked Lists
Recursion
Algorithms
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.
This kata "assumes" that you should have OOP basic knowledge.
"Additionally, this Kata assumes that you have basic knowledge of Object-Oriented Programming ( or a similar concept ) in the programming language you are undertaking. If you have not come across Object-Oriented Programming in your selected language, you may want to try out an online course or read up on some code examples of OOP in your selected language up to ( but not necessarily including ) Classical Inheritance."
Although, this is not necessary because you don't need that. The language can be not object-oriented (like C) neither the algorithm requires and/or uses inheritance.
I suggest to remove this paragraph for better clarity.
you can just call constructor recursively for one-liner
Simple and funny kata)
Been learning a lot about c data structures like linked list lately and i wanted to solve some probs like this and i really enjoyed it, if u culd make more prob on data structures this would be great !
NASM translation
slowly getting linked list
While solving the kata I received this error code: The expression (linked_list_eq(&((Node){ .data = 1, .next = &((Node){ .data = 2, .next = &((Node){ .data = 3, .next = ((void*)0) }) }) }),parse("1 -> 2 -> 3 -> NULL"))) == (1) is false.
It wasn't really helpful. Maybe this could be amended. Thank you, I liked the Kata.
Java translation
approved
This comment has been hidden.
Great idea: fork making it so
Should JS ( and other languages ) do the same? I suspect
repr
is analogous toJSON.stringify
( and Haskellshow
, and others ).Thanks for posting this. Helped me troubleshoot my code as well.
Yeah, I was getting that same error today until I figured it out.
very cool!
Updated to Scala 3
This comment has been hidden.
fixed
Python translation
Approved, thanks!
Oh data type was str, not int -> error message is a bit obscure
Good that you wrote it. I had the same problem :D
1 -> 2 -> 3 -> None should equal 1 -> 2 -> 3 -> None
0 -> 1 -> 4 -> 9 -> 16 -> None should equal 0 -> 1 -> 4 -> 9 -> 16 -> None
fixed by mauro-chabby combo
c: the input string is actualy a
const
added the modifier to the prototype
Nice kata!
JavaScript: `Expected: Node { data: 1, next: Node { data: 2, next: Node { data: 3, next: null } } },
instead got: Node { data: 1, next: Node { data: 2, next: Node { data: 3, next: null } } }`
Can anyone look at this please
I'm not able to explain technically, but I thought the problem comes from the fact that you redefine
Node
inside your code, while you should use the preloaded class. I could have your code working by just removing all theclass Node
part, and declaringinsert
asNode.prototype.insert function(val) ...
outsideparse
.worked. thanks :D
COBOL translation, please review carefully.
This was challenging to figure out..... lord have mercy. Nothing puts you in your place more than submitting your solution (20-30 lines of code) then you see a solution that is 1 line. lol rest in peace.
Haskell translation
Approved
Astonising texts for failing tests. This kata brings a lot of fun.
Thank you.
The Next property shall better be defined similar to the following in C#
public Node Next {get; private set;}
Otherwise it is not challenging. Similar constraints can be done in all other languages
This comment has been hidden.
Well, I just tried out the C# version of this Kata with your
using
directives andParse
method body as-is (i.e. without any modifications whatsoever) and it passed all Submit tests as expected so I don't see what's the problem here. Keep in mind that theNode
class displayed to you in the Kata Description is already defined in Preloaded so you don't need to redefine it yourself (in fact, you shouldn't).I'm getting this error when running it in JS:
Error: kata.js: Unexpected token, expected , (27:50)
To all those who may want to translate my Kata,
Feel free to translate my Kata into any language you like! This Kata is not meant to be PHP-specific.
Cheers, donaldsebleung :D