For quite some time I found my time procastinating after getting home from work. Untill a few days ago I stumbled upon the Daily Coding Problem (DC...
For further actions, you may consider blocking this person and/or reporting abuse
In Javascript, JSON serialization/unserialization is already supported, so this felt like cheating:
Exactly man, I looked at it, and thought, what?? They're asking one thing that already exists?
The tricky part is to make it work for arbitrary values, i.e. drop the assumption the symbols for Empty_Marker and '-' are not going to be used in any node's value.
Here's such a solution in Perl, tests included:
Python solution defining
__repr__
, which is meant for exactly this purpose:Edit: Included test from problem statement in the code, so that it should now be ready for copy and paste into file and
python3 -i <file>
. While we are at it, implemented__eq__
and__hash__
, so that we can assert even stronger tests.Quite impressive, thank you!
I think this is a minimal and fast solution :
Go solution. Its a bit verbose as it does not have optional/default params.
Here's my C# solution
Python solution using recursion.
My first time to see someone using Lua, thanks for the code, cool!