« first day (48 days earlier)      last day (204 days later) » 

01:09
.
week is over
I'll probably try to look it over tomorrow hopefully
 
20 hours later…
21:11
let me know
I can guarantee that this terminates, by the way. Recursion depth that replaces the tree is limited by x, which only strictly decreases, so it suffices to show that traversing each individual tree terminates:
Let the depth-first search of nodes in the tree be D = [1, ..., 0,0,...0]. Let d_i denote the number of 0 nodes that are children of the node represented by D's ith element.
And let the number of 0 nodes after this node in traversal order be C_i. Traversal order means any 0 node that is a child of any node to the right of the i'th node and to the right of the i'th node's ancestors.
21:37
Traversing through a branch node with value 0 at index i will cause the number of 0s in D to increase by C_i * (d_i-1) -1. Leaf nodes will cause a decrease of 1 to the same quantity.
In the simplest case, where there are no 0 nodes, it's trivial to see that traversal will complete; the tree gets read as a large series of nested for loops.
In a tree with 0s only as leaves, it is also trivial to see that no expansion of the tree occurs, and execution will terminate.
(the above is why I do replacements with t(x,3) before recursing, so I can guarantee to not get stuck like that and miss out on growth.)
Now for a slightly more complicated case, with one branch 0. It will replace all the leaf nodes after it in traversal order with 0s, but after that the tree becomes one with only 0s as leaves again.
Starting to generalize, a replacement will make future branches larger but will make future replacements smaller and smaller until they become nonexistent. Since it only affects future branches, there's no way to make recursion infinite.
Eventually, the only 0s will be on leaves, which will replace themselves and then execution will terminate.

« first day (48 days earlier)      last day (204 days later) »