TowerOfHanoi | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

TowerOfHanoi

this is just for fun solve the tower of Hanoi in any language 1.you have 3 towers 2.the first one has an n amount of discs(going from big to small bottom to top) the other two towers are empty. 3.you can only move one disc at a time 4.a disc cannot go on top of a smaller disc 5.the goal is to get all discs from the first tower onto the third look it up if you are unclear.. I'm hoping to see at least one answer that isn't completely unrelated.

16th Nov 2016, 2:54 AM
Remmiq Sliv
Remmiq Sliv - avatar
1 Answer
+ 8
#python, hanoi towers def move(n, x, y): z = 6 - x - y if n > 0: move(n-1, x, z) print(n, x, y) move(n-1, z, y) n = int(input()) move(n, 1, 3)
8th Jan 2017, 4:02 PM
Sergey