AndreiL
Welcome to AndreiL.
Enjoy your time.
Please log in.

Number of moves in Hanoi - Python algorithm

Go down

Number of moves in Hanoi - Python algorithm

Post by Lucaci Andrei on Mon Feb 13, 2012 5:40 am

1
2
3
4
5
6
7
8
def hanoi(n):
if n == 0:
return False
else:
return ((2 * (hanoi(n - 1)) + 1))

n = input("N>=1, n= ")
print "The required number of moves: ", hanoi(n)

avatar
Lucaci Andrei
"Tata Lor"


Number of messages : 222
Points : 2266743
Reputation : 1007
Registration date : 2008-08-15
Age : 26
Location : Cluj-Napoca

View user profile http://www.andreil.wgz.ro

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum