f
without using explicit ordinals: 19:06
@SimplyBeautifulArt All right, so my next idea that I think breaks
Let `r = t(x, n)` transform a bitstring `x` into a balanced tree `r` where each node has a binary value and `n` children, padding `x` to the right so that all leaves have a value of `0`.
Let `x = N(r)` be the inverse of this operation, but without the binary value restriction on nodes or the balanced-tree restriction. It does not remove padding.
Let `x = N(r)` be the inverse of this operation, but without the binary value restriction on nodes or the balanced-tree restriction. It does not remove padding.
For notational convenience, let
tree.v
denote the value of the root node, the tree[0], tree[1],...,tree[tree.n - 1]
denote the n
children, tree.p
denote the parent, and tree.pn
denote the index of tree
within tree.p
(i.e. tree.p[tree.pn]
should equal tree
).
Also, define a function R(ReplaceIn, ReplaceWith) to replace all nodes with a value of 0 in ReplaceIn but not in or depth-first-search-wise preceeding ReplaceWith with ReplaceWith, copying the children of the original 0 node to every leaf of the replacing ReplaceWith.
h(x, Tree, Root) = m += N(Root) if x >= 0: if Tree.v == 0: Tree.v = m or 1 if Tree.n > 0: # i.e. this is not a leaf R(Root,Tree) for i in range(m): m += N(Root) j = R(t(m+1,3),t(x,3)) h(x-1, j,j) else: Tree.v += m for i in range(Tree.v): for a in range(Tree.n): h(x,Tree[a], Root) if Tree.pn + 1 < Tree.p.n: h(x,Tree.p[Tree.pn + 1], Root) return m
And, since we love examples, let's do a few (meaning one and a little bit):
g(0) = h(0, [0], [0])
m += N([0]) = 0
[0].v == 0, so we go down the first path
After we replace the 0 with 1, there's no 0 nodes in Root, and m = 0 to begin with so we don't go through this for loop at all ._.
g(0) = 0
g(0) = h(0, [0], [0])
m += N([0]) = 0
[0].v == 0, so we go down the first path
After we replace the 0 with 1, there's no 0 nodes in Root, and m = 0 to begin with so we don't go through this for loop at all ._.
g(0) = 0
g(1) = h(1, t(1,3),t(1,3))
t(1,3) pads the 1 so that it has three `0` children, making the bitstream 1000 and the tree itself [1,[0],[0],[0]]. N(t(1,3)) = 8
h(1,[1,[0],[0],[0]], [1,[0],[0],[0]])
I'll call the reference to the original root `a` for convenience
m += 8
a = [1+8=9, [0],[0],[0]]
now iterating 9 times:
a = [9, [m],[0],[0]]
m += base2(1001100100) = (in the first iteration) base2(1001101100)
Now we get to fun stuff that starts to get grotesquely big, and I start to lose track.
I'm just going to go through the first iteration.
t(1,3) pads the 1 so that it has three `0` children, making the bitstream 1000 and the tree itself [1,[0],[0],[0]]. N(t(1,3)) = 8
h(1,[1,[0],[0],[0]], [1,[0],[0],[0]])
I'll call the reference to the original root `a` for convenience
m += 8
a = [1+8=9, [0],[0],[0]]
now iterating 9 times:
a = [9, [m],[0],[0]]
m += base2(1001100100) = (in the first iteration) base2(1001101100)
Now we get to fun stuff that starts to get grotesquely big, and I start to lose track.
I'm just going to go through the first iteration.
pyth.herokuapp.com/… If you're having a tough time visualizing how t works, here it is in program form!
19:35
pyth.herokuapp.com/?code=ius.esFbk.g%2BIk%5B%29GQ%292 And likewise for N; copypaste output from t into N and it'll be larger by a fair amount because they're more worried about largeness than correctness
« first day (42 days earlier) ← previous day next day → last day (210 days later) »