Skip to content

Commit 70bd0c5

Browse files
added a solution to solve tower of Hanoi game
1 parent da8cb8f commit 70bd0c5

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Python/towerofHanoi.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def TowerOfHanoi(n , source, destination, auxiliary):
2+
if n == 1:
3+
print(f"1:{source}->{destination}")
4+
return
5+
TowerOfHanoi(n - 1, source, auxiliary, destination)
6+
print(f"{n}:{source}->{destination}")
7+
TowerOfHanoi(n - 1, auxiliary, destination, source)

0 commit comments

Comments
 (0)