Answer the question
In order to leave comments, you need to log in
Reading binary trees from an archive in Ruby?
Need help. There is an archive trees.zip with files like: barbra.tree, caryl.tree and so on. Inside each file is a serialized tree in JSON format in the form: [1 ,,[3,[5,2]]]]
For example, one of the aline.tree files contains the following code inside:
[29,]],[24,]],[15,,[25,[42,2]]]]]]]],[18,,[19,,[26,[38,0]]]]]],[16,]],[22,,[31,[9,5]]]]]]]]]],[41,]]]],[41,]],[17,,[35,[42,18]]]]]]]],[35,,[49,,[34,[44,44]]]]]],[5,]],[40,,[12,[47,7]]]]]]]]]]]]
1
/ \
2 3
/ \ / \
3 4 5 2
$ NAME=small ruby trees.rb
1
/ \
2 3
/ \ / \
3 4 5 2
$ NAME=funny ruby trees.rb
Данное дерево не растет в данном лесу.
$ ruby trees.rb
Безымянных деревьев у нас не растет.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question