New Exercise Proposal: Tower of Hanoi

Would it be interesting to emulate the game? The inputs could be the disks (by size) on each tower and the moves, eg [1,2,3],[],[4] combined with moves (from, to), eg 1-2, 1-3, 2-3.

The program could detect invalid set up or invalid moves and report the final towers.

I think the k poles version, returning the number of steps, would be interesting.

I’ll implement a couple of different solutions.

Two solutions for the k poles version:

Solution using Frame–Stewart - students using languages with fixed-size integers will need to be careful if we have hundreds of discs.

Solution using exhaustive BFS - only feasible with a small number of discs.

Personally, I don’t find it very interesting to search for and implement a niche formula. I find the BFS more interesting; however, we already have several problems that can be solved with BFS (eg Go, Connect) so I’m not sure how interesting/novel another BFS problem would be.

1 Like