Created
September 26, 2016 14:52
-
-
Save devils-ey3/d65411aa8353ced7ee3741a00f9ac0de to your computer and use it in GitHub Desktop.
This file contains hidden or 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
count=0 | |
def printMove(fr,to): | |
global count | |
count+=1 | |
print('move from '+str(fr)+' to '+str(to)) | |
def Tower(n,fr,to,spare): | |
if n==1: | |
printMove(fr,to) | |
else: | |
Tower(n-1,fr,spare,to) | |
Tower(1,fr,to,spare) | |
Tower(n-1,spare,to,fr) | |
Tower(10,'P1','P2','P3') | |
print(count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment