Skip to content

Instantly share code, notes, and snippets.

@edprince
Last active October 27, 2015 10:23
Show Gist options
  • Save edprince/68b8dbc056651f2f3074 to your computer and use it in GitHub Desktop.
Save edprince/68b8dbc056651f2f3074 to your computer and use it in GitHub Desktop.
A recursive algorithm extending the koch snowflake
import turtle
from random import randint
u = 0
turtle.speed(0)
turtle.delay(0)
#turtle.tracer(0, 0)
def koch(x, m):
if x < m:
turtle.forward(x)
else:
koch(x / 3, m)
turtle.left(60)
koch(x / 3, m)
turtle.right(120)
koch(x / 3, m)
turtle.left(60)
koch(x / 3, m)
def repeat():
u = 0
for x in range(3):
koch(500, 5)
turtle.right(120)
u += 1
turtle.right(20)
if u < 1000000:
repeat()
repeat()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment