From aa59a64750330699b1d50679e06e02d287eba51c Mon Sep 17 00:00:00 2001 From: lolabird Date: Thu, 29 Feb 2024 12:21:53 -0700 Subject: [PATCH] Remove unnecessary variables --- thinkcspy/Chapter-16-Exercises/Problem6and12_hanoi.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/thinkcspy/Chapter-16-Exercises/Problem6and12_hanoi.py b/thinkcspy/Chapter-16-Exercises/Problem6and12_hanoi.py index 655f104..4352e24 100644 --- a/thinkcspy/Chapter-16-Exercises/Problem6and12_hanoi.py +++ b/thinkcspy/Chapter-16-Exercises/Problem6and12_hanoi.py @@ -9,24 +9,19 @@ def stackTowers(num, turts): A = [] B = [] C = [] - rounds = 0 rods = {"A":A, "B":B, "C":C} for i in range(num): A.insert(0, i+1) - def hanoi(num, start, aux, end, turts): - nonlocal rounds - + def hanoi(num, start, aux, end, turts): if num == 1: end += [start.pop()] - rounds += 1 moveTurtles(turts[end[-1] - 1], rods) else: hanoi(num - 1, start, end, aux, turts) end += [start.pop()] - rounds += 1 moveTurtles(turts[end[-1] - 1], rods) hanoi(num -1, aux, start, end, turts) @@ -54,8 +49,6 @@ def generateColor(): def createTurtles(num): turtles = [] - totalHeight = num*15 - for i in range(num): newTurt = turtle.Turtle() newTurt.shape("square")