Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

tower of hanoi python

def TowerOfHanoi(n , s_pole, d_pole, i_pole):           
    if n == 1:
        print("Move disc 1 from pole",s_pole,"to pole",d_pole)
        return
    TowerOfHanoi(n-1, s_pole, i_pole, d_pole)
    print("Move disc",n,"from pole",s_pole,"to pole",d_pole)
    TowerOfHanoi(n-1, i_pole, d_pole, s_pole)
 
n = 3
TowerOfHanoi(n, 'A', 'C', 'B')
# A, C, B are the name of poles
Comment

PREVIOUS NEXT
Code Example
Python :: colab version python 
Python :: get variable name python 
Python :: reload flask on change 
Python :: saving model in pytorch 
Python :: flask heroku 
Python :: how to print without space in python 3 
Python :: Get files from S3 bucket Python 
Python :: python how to print input 
Python :: pandas nan to none 
Python :: non-integer arg 1 for randrange() 
Python :: clone website 
Python :: pandas rename column values dictionary 
Python :: django dockerfile multistage 
Python :: python count code, Count number of occurrences of a given substring 
Python :: dataframe KeyError: 
Python :: count list python 
Python :: python find object with attribute in list 
Python :: flask python use specified port 
Python :: types of system 
Python :: python get unique pairs from two lists 
Python :: add x=y line to scatter plot python 
Python :: ros python service server 
Python :: pandas read csv skip rows 
Python :: pdf to csv 
Python :: how does urllib.parse.urlsplit work in python 
Python :: python replace all in list 
Python :: 3d array numpy 
Python :: find the difference in python 
Python :: string to list python 
Python :: extract int from string python 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =