Created
November 10, 2010 21:53
-
-
Save sayz/671600 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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