Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4a3813f

Browse files
author
Rohit Gangwar
committedOct 10, 2024·
Merge branch 'backtracking-tower_of_hanoi' of https://github.com/rohit8020/Python-Algorithms into backtracking-tower_of_hanoi
2 parents 09797a1 + 017364b commit 4a3813f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed
 

‎backtracking/tower_of_hanoi.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def tower_of_hanoi(n, source, destination, auxiliary):
2121
print(f"Move disk {n} from peg {source} to peg {destination}")
2222
tower_of_hanoi(n - 1, auxiliary, destination, source)
2323

24+
2425
# Example usage:
2526
n = 3 # Number of disks
2627
tower_of_hanoi(n, 1, 3, 2)
@@ -51,6 +52,6 @@ def tower_of_hanoi(n, source, destination, auxiliary):
5152
# Move disk 3 from peg 1 to peg 3
5253
# Move disk 1 from peg 2 to peg 1
5354
# Move disk 2 from peg 2 to peg 3
54-
# Move disk 1 from peg 1 to peg  
55+
# Move disk 1 from peg 1 to peg
5556
# 3
56-
# This output demonstrates the correct sequence of moves to solve the Tower of Hanoi problem with 3 disks.
57+
# This output demonstrates the correct sequence of moves to solve the Tower of Hanoi problem with 3 disks.

0 commit comments

Comments
 (0)
Please sign in to comment.