Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1 @@
root = BinaryTreeNode.from_array [1, [2, [4, 7], [5]], [3, [6, [8], [9]]]]

View file

@ -0,0 +1,2 @@
require 'pp'
pp root

View file

@ -0,0 +1,12 @@
def ptree(tree,indent=" ")
case tree
when Array
head,*tail=tree
ptree(head,indent)
s=tail.size-1
tail.each_with_index { |tree1,i| ptree(tree1,"#{indent}#{((i==s) ? ' ':'|')} ") }
else
puts(indent.gsub(/\s\s$/,"--").gsub(/ --$/,"\\--")+tree.to_s)
end
end
ptree [1,2,3,[4,5,6,[7,8,9]],3,[22,33]]