You all must have seen or heard about this amazing game i.e. Tower of hanoi. In this game we have to shift all blocks from one tower to another without violating the order of size which is upper box should be smaller than the lower box as shown here in diagram
So why holding your excitement lets go right into it. We will be using python as it is eazy to implement and understand.
So our code goes as:-
def tower(n,s,h,d):
if n==0:
return
tower(n-1,s,d,h)
print("Move",n,"from",s,"to",d)
tower(n-1,h,s,d)
n = int(input("Enter n: "))
tower(n,"Source","helper","destination")
And we can apply it as :-
So if you apply this method as we got in our output your destination
Tower will complete without violating any rules and it will look like:- So hope you enjoyed this small game we will meet soon with amazing game with awesome graphics too. Till then peace out :)