Tests in Ruby seem to be broken:
#<NoMethodError: undefined method `add' for main:Object>
main.rb:24:in `block (2 levels) in <main>'
Solution passes Attempt and submission though.
Way too easy for 4kyu
Looked it up because I am still learning about class syntax BUT seeing the solution it appears to be too easy for 4 kyu :/
Good to know, new to codewars so learning new things everyday.
Can't be changed.
Way too easy for a 4 kyu, this is a very common problem so at the most should be a 6 kyu.
Ruby 3.0 should be enabled (Refer this & this for more detail)
yeah, you're right, sorry about that
You would be surprised how many people failed to come up with the solution. The fact something is basic for you doesn't mean it's basic for everyone.
Have you actually tried printing what that solution returns? Why do you assume the test is broken? there are over 700 passed solutions to this. Wouldn't it make more sense to assume it's your solution that is broken?
Try building a tree provided as an example, and see if your solution prints the expected output.
Hint: the result of a function in ruby is the last expression in it. in your case, it's
Do you think that call will return the expected call?
This comment is hidden because it contains spoiler information about the solution
It's too easy to 4kyu kata, levels/ pre-order / inorder/ postorder traversal are basic, unless require do it iteratively or recursive, or O(1) space cost(besides return list cost)
And I think the return list, that its item's type should be clear,
[1, 2, 3] is int: 1, 2, 3 ? or Node(1), Node(2), Node(3) which are the root node's children.
int: 1, 2, 3
Node(1), Node(2), Node(3)
Returning the values the nodes hold rather than the nodes themselves resolves it for sure.