Created
November 1, 2018 06:47
-
-
Save gaxiiiiiiiiiiii/48e81bbfa27768b4d59b2ad91449004b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def build_layer(self): | |
new_layer = [] | |
if len(self.layer) % 2 == 1: | |
self.layer.append(self.layer[-1]) | |
for i in range(0, len(self.layer), 2): | |
left = self.layer[i] | |
right = self.layer[i+1] | |
parent = Node(left.hash + right.hash) | |
left.parent = parent | |
left.sibling = right | |
left.position = "left" | |
right.parent = parent | |
right.sibling = left | |
right.position = "right" | |
parent.left = left | |
parent.right = right | |
new_layer.append(parent) | |
self.layer = new_layer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment