Skip to content

Commit

Permalink
Minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Carleslc committed Feb 14, 2022
1 parent 8914520 commit af94140
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
10 changes: 5 additions & 5 deletions Hanoi Towers/hanoi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-

# HANOI'S TOWER
# https://en.wikipedia.org/wiki/Tower_of_Hanoi
# Minimum number of moves: 2^n + 1

import argparse
Expand All @@ -16,11 +17,10 @@ def hanoi(n, src, dest, aux):
if n == 1:
print(f"{src} -> {dest}")
return 1
else:
moves = hanoi(n - 1, src, aux, dest)
moves += hanoi(1, src, dest, aux)
moves += hanoi(n - 1, aux, dest, src)
return moves
moves = hanoi(n - 1, src, aux, dest)
moves += hanoi(1, src, dest, aux)
moves += hanoi(n - 1, aux, dest, src)
return moves

if __name__ == "__main__":
set_args()
Expand Down
1 change: 0 additions & 1 deletion Knight Tour/knight-tour-8.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import chess.svg

from app import App
from window import Window

def set_args():
global args
Expand Down

0 comments on commit af94140

Please sign in to comment.