Skip to content

Instantly share code, notes, and snippets.

@luizomf
Created March 30, 2020 17:43
Show Gist options
  • Select an option

  • Save luizomf/7485cf4c7e459d231b22fcd83a13f0b5 to your computer and use it in GitHub Desktop.

Select an option

Save luizomf/7485cf4c7e459d231b22fcd83a13f0b5 to your computer and use it in GitHub Desktop.
# Torre de Hanói
def hanoi(disco: int, origem: str, auxiliar: str, destino: str) -> None:
if disco <= 0:
return
hanoi(disco - 1, origem, destino, auxiliar)
print(f'Movendo disco {disco} de {origem} para {destino}')
hanoi(disco - 1, auxiliar, origem, destino)
if __name__ == "__main__":
hanoi(3, 'Origem', 'Auxiliar', 'Destino')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment