User blog:QuasarBooster/A new way to think of Buchholz hydras? As worms?

I was contemplating whether hydras could be implemented without using nested arrays when I thought of a potential candidate. If you ignored all the inner lists and just wrote out each entry as you normally would for a hydra (i.e. prefix traversal), then you would obviously lose important information about the hydra's structure. [+,[0,[1],[1],[1],[0,[1],[1],[1],[0]]]] -> [+,0,1,1,1,0,1,1,1,0] However, I think there is a simple solution. If each label were followed by an entry describing the node's depth in the tree, then I think that would preserve all of the hydra's structure. (Let's also ignore the root node) [+,[0,[1],[1],[1],[0,[1],[1],[1],[0]]]] -> [0,0,1,1,1,1,1,1,0,1,1,2,1,2,1,2,0,2] I'm pretty sure this method works for any hydra but I haven't proved anything. That's primarily why I'm writing this post; if any of you could confirm or refute this method then I'd love to know. I'm going to assume that it preserves hydras as intended in order to create a slimmed-down program that calculates \(\text{BH}(n)\). As a sidenote, I notice a lot of similarities between this single-list version of hydras and Beklemishev worms. To the right is an example of how to convert a Buchholz hydra into a "hydra-worm". The root node is ignored and all integer labels on the hydra are increased by one to allow omega-labels to be represented with 0. The hydra's nodes are then added prefix-style to the worm, along with their depths (a child of the root node has depth 0). The rules for Buchholz hydras are carried out as normal, albeit on a worm instead of a nested array structure. I've tested my program for the inputs 1 through 5 and they all seem to show the expected behavior. def BH(n): k=0 H=[] for i in range(n-1):H+=[i<1,i] while H:   k+=1 d=H.pop u=H.pop if d:     i=0 l=len(H) for j in range(2,l,2): if H[j+1]1: for j in range(l+3,len(H),2):H[j]+=d-H[i+1] return k