Last active
December 9, 2018 18:08
-
-
Save kadirmalak/5945569f43bf1a954ac72d068e21a15b 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 ifor(*lists): | |
root = Node('ROOT') | |
for L in lists: | |
leaves = list(root.leaves()) | |
for data in L: | |
# create once, use multiple times | |
# this way we end up with a graph, instead of a tree | |
new_node = Node(data) | |
for leaf in leaves: | |
# leaves() function may return same nodes multiple times | |
if not new_node in leaf.children: | |
leaf.add(new_node) | |
return root.routes_to_leaves() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment