Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

42 lines (35 sloc) 0.979 kB
n = 20
mindepth = 4
maxdepth = mindepth + 2
if (maxdepth < n): maxdepth = n.
new_tree = (item, depth):
if (depth > 0):
i = item + item, depth--
(item, new_tree(i - 1, depth), new_tree(i, depth)).
else:
(item).
.
item_check = (tree):
if (tree(2)):
tree(0) + item_check(tree(1)) - item_check(tree(2)).
else:
tree(0).
.
stretch_depth = maxdepth + 1
check = item_check(new_tree(0, stretch_depth))
("stretch tree of depth ", stretch_depth,
"\t check: ", check, "\n") join print
longlivedtree = new_tree(0, maxdepth)
depth = mindepth, while (depth <= maxdepth):
iter = 1 << (maxdepth - depth + mindepth)
check = 0
i = 1
while (i <= iter):
check = check + item_check(new_tree(1, depth)) +
item_check(new_tree(-1, depth))
i++.
(iter * 2, "\t trees of depth ", depth,
"\t check: ", check, "\n") join print
depth = depth + 2.
("long lived tree of depth ", maxdepth, "\t check: ",
item_check(longlivedtree), "\n") join print
Jump to Line
Something went wrong with that request. Please try again.