2018/08.py
def read_node(i, d=0) -> Tuple[Node, int]:
    """
    Read in the node starting at index `i`. This is a recursive function that returns
    the node and the index that should be processed next (the one right after the last
    index we processed).
    """
    N, M = seq[i], seq[i + 1]  # number of children nodes and number of metadata items
    i += 2

    # Read in the children
    children = []
    for _ in range(N):
        node, i = read_node(i, d + 1)
        children.append(node)

    # Read in the metadata
    metadata = []
    for _ in range(M):
        metadata.append(seq[i])
        i += 1

    # Conver to tuples and return along with the index that we processed up to.
    return ((tuple(children), tuple(metadata)), i)

    Read in the node starting at index `i`. This is a recursive function that returns
    the node and the index that should be processed next (the one right after the last
    index we processed).
    
Read in the node starting at index `i`. This is a recursive function that returns
the node and the index that should be processed next (the one right after the last
index we processed).
Read in the node starting at index ` i ` . This is a recursive function that returns the node and the index that should be processed next ( the one right after the last index we processed ) .
def read_node(i, d=0) -> Tuple[Node, int]:
    N, M = seq[i], seq[i + 1]  
    i += 2
    children = []
    for _ in range(N):
        node, i = read_node(i, d + 1)
        children.append(node)
    metadata = []
    for _ in range(M):
        metadata.append(seq[i])
        i += 1
    return ((tuple(children), tuple(metadata)), i)
def read_node ( i , d = 0 ) -> Tuple [ Node , int ] : N , M = seq [ i ] , seq [ i + 1 ] i += 2 children = [ ] for _ in range ( N ) : node , i = read_node ( i , d + 1 ) children . append ( node ) metadata = [ ] for _ in range ( M ) : metadata . append ( seq [ i ] ) i += 1 return ( ( tuple ( children ) , tuple ( metadata ) ) , i )
Read in the node starting at index `i`.
Read in the node starting at index ` i ` .
"""
    Read in the node starting at index `i`. This is a recursive function that returns
    the node and the index that should be processed next (the one right after the last
    index we processed).
    """ # number of children nodes and number of metadata items # Read in the children # Read in the metadata # Conver to tuples and return along with the index that we processed up to.
i
d