Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

Tower of Hanoi

def towerOfHanoi(N , source, destination, auxiliary):
	if N==1:
		print("Move disk 1 from source",source,"to destination",destination)
		return
	towerOfHanoi(N-1, source, auxiliary, destination)
	print("Move disk",N,"from source",source,"to destination",destination)
	towerOfHanoi(N-1, auxiliary, destination, source)
		
# Driver code
N = 3
towerOfHanoi(N,'A','B','C')
# A, C, B are the name of rods
Source by favtutor.com #
 
PREVIOUS NEXT
Tagged: #Tower #Hanoi
ADD COMMENT
Topic
Name
9+3 =