Use list comprehension to initialize paths
`[[]] * length` creates an array of the correct length, but where every entry is an alias to the same inner array. Pushing to any of the arrays was behaving as if we were pushing to all of them, instead of updating independent paths.
This commit is contained in:
parent
9e1563af0d
commit
33a95555dc
|
@ -60,7 +60,7 @@ def main():
|
|||
# Derive path for each leaf in a tree of depth 4.
|
||||
def get_paths_and_root(leaves):
|
||||
assert(len(leaves) == (1 << SMALL_DEPTH))
|
||||
paths = [[]] * (1 << SMALL_DEPTH)
|
||||
paths = [[] for _ in range(1 << SMALL_DEPTH)]
|
||||
|
||||
# At layer 0, we want:
|
||||
# - leaf 0: sibling 1
|
||||
|
|
Loading…
Reference in New Issue