From 78d016a9c1398a8e55cc1ca4b4e43fed07892d69 Mon Sep 17 00:00:00 2001 From: ChUrl Date: Fri, 16 Dec 2022 17:43:21 +0100 Subject: [PATCH] Cleanup --- hanoi.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hanoi.py b/hanoi.py index 30fa115..fd2413a 100755 --- a/hanoi.py +++ b/hanoi.py @@ -1,13 +1,16 @@ #!/usr/bin/env python3 -def solve_hanoi(disks, from_pin, to_pin, aux_pin): +from rich.traceback import install +install() + +def hanoi(disks, from_pin, to_pin, aux_pin): if disks == 1: print("Move disk from pin", from_pin, "to", to_pin) return - solve_hanoi(disks - 1, from_pin, aux_pin, to_pin) # Move all disks except the last to the auxiliary pin + hanoi(disks - 1, from_pin, aux_pin, to_pin) # Move all disks except the last to the auxiliary pin print("Move disk from pin", from_pin, "to", to_pin) # Move the last disk to the target pin - solve_hanoi(disks - 1, aux_pin, to_pin, from_pin) # Move all disks from the auxiliary pin to the target pin + hanoi(disks - 1, aux_pin, to_pin, from_pin) # Move all disks from the auxiliary pin to the target pin -solve_hanoi(10, 1, 3, 2) +hanoi(3, 1, 3, 2)