Skip to content

Instantly share code, notes, and snippets.

@Jonty
Created May 10, 2014 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jonty/4fa32499a48a54a599a3 to your computer and use it in GitHub Desktop.
Save Jonty/4fa32499a48a54a599a3 to your computer and use it in GitHub Desktop.
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