-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspirals.py
36 lines (29 loc) · 1.05 KB
/
spirals.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'''
Created on Feb 25, 2019
@author: Bharddwaj Vemulapalli
username: bvemulap
I pledge my honor that I have abided by the Stevens Honor System.
'''
import turtle
def square_spiral(walls):
def square_spiral_helper(distance, initial, count):
if walls == count:
turtle.done()
else:
turtle.left(90)
turtle.forward(distance)
square_spiral_helper(distance + initial * (count % 2), initial, count + 1)
square_spiral_helper(20, 20, 0)
def octagonal_spiral(walls):
def octagonal_spiral_helper(distance, initial, count):
if walls == count:
turtle.done()
else:
turtle.left(45)
turtle.forward(distance)
octagonal_spiral_helper(distance + initial * (count % 2), initial, count + 1)
octagonal_spiral_helper(20, 5, 0)