Skip to content

Commit 67c2a36

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 618f6e1 commit 67c2a36

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

divide_and_conquer/tower_of_hanoi.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Towers of Hanoi is a mathematical puzzle that is solved using a recursive
2+
Towers of Hanoi is a mathematical puzzle that is solved using a recursive
33
divide-and-conquer strategy.
44
55
It moves a stack of disks from a source pole to a destination pole,
@@ -14,7 +14,9 @@
1414
"""
1515

1616

17-
def tower_of_hanoi(n: int, source: str = "A", auxiliary: str = "B", destination: str = "C") -> list[tuple[str, str]]:
17+
def tower_of_hanoi(
18+
n: int, source: str = "A", auxiliary: str = "B", destination: str = "C"
19+
) -> list[tuple[str, str]]:
1820
"""
1921
Pure python implementation of the Towers of Hanoi puzzle (recursive version),
2022
returning the sequence of moves required to solve the puzzle.
@@ -53,7 +55,9 @@ def solve_hanoi(n: int, source: str, auxiliary: str, destination: str):
5355

5456
if __name__ == "__main__":
5557
try:
56-
n_disks = int(input("Enter the number of disks for the Tower of Hanoi: ").strip())
58+
n_disks = int(
59+
input("Enter the number of disks for the Tower of Hanoi: ").strip()
60+
)
5761
if n_disks < 0:
5862
print("Please enter a non-negative number of disks.")
5963
else:

0 commit comments

Comments
 (0)