diff --git a/TowerOfHanoi b/TowerOfHanoi new file mode 100644 index 0000000..21bb020 --- /dev/null +++ b/TowerOfHanoi @@ -0,0 +1,11 @@ +def tower_of_hanoi(n, source, auxiliary, target): + if n == 1: + print(f"Move disk 1 from {source} to {target}") + return + tower_of_hanoi(n-1, source, target, auxiliary) + print(f"Move disk {n} from {source} to {target}") + tower_of_hanoi(n-1, auxiliary, source, target) + +n = int(input(" Enter number of disks : ")) +tower_of_hanoi(n, 'A', 'B', 'C') +print(" **SOLVED** ")