Skip to content

Instantly share code, notes, and snippets.

@sayz
Created November 10, 2010 21:53
Show Gist options
  • Save sayz/671600 to your computer and use it in GitHub Desktop.
Save sayz/671600 to your computer and use it in GitHub Desktop.
#! /usr/bin/python
#-*-coding:utf-8-*-
import sys
hata = 'hanoi.hata'
def move(nerden, nereye):
print 'taşı %s --> %s' % (nerden, nereye)
def hanoiyap(n, nereye, nerden, using):
if n == 0: return []
hanoiyap(n-1, using, nerden, nereye);
move(nerden, nereye);
hanoiyap(n-1, nereye, using, nerden);
def main():
if len(sys.argv) > 1:
for arg in sys.argv[1:]:
n = eval(arg)
hanoiyap(n, 3, 1, 2)
else:
try:
while 1:
n = input()
hanoiyap(n, 3, 1, 2)
except EOFError:
pass
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment