Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def hanoi(n,A,C,B):
- #@param:
- # n: int, number of rings;
- # A: str, initial pole;
- # C: str, destination pole;
- # B: str, empty pole;
- if n==1:
- print("Move ring from",A,"to",C)
- else:
- hanoi(n-1,A,B,C)
- print("Move ring from",A,"to",C)
- hanoi(n-1,B,C,A)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement