Created
May 10, 2014 16:18
-
-
Save Jonty/4fa32499a48a54a599a3 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
import random | |
class Node: | |
def __init__(self, children): | |
self.children = [] | |
root = Node([]) | |
nodes_to_process = [root] | |
count = 0 | |
while nodes_to_process and count < 50: | |
count += 1 | |
node = nodes_to_process.pop(0) | |
for _ in range(0, random.randint(0, 3)): | |
child = Node([]) | |
node.children.append(child) | |
nodes_to_process.append(child) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment