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:
Jack Grigg 2021-09-13 22:36:44 +01:00
parent 9e1563af0d
commit 33a95555dc
1 changed files with 1 additions and 1 deletions

View File

@ -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