ScratchData LogoScratchData
Back to papipupepappa's profile

Tower of Hanoi

PApapipupepappa•Created April 9, 2021
Tower of Hanoi
73
55
1281 views
View on Scratch

Instructions

Choose the number of pegs and discs, and click start. Then try to move the discs to the rightmost peg (marked with a dot) with as few moves as possible. Click and drag to move a disc. Rules: ● You can only move one disc at a time. ● You cannot place a disc on a smaller disc.

Description

Huge thanks to @gregatku who inspired me to make this, both with his own Tower of Hanoi project and many supportive comments: https://scratch.mit.edu/projects/133945156/ My biggest trouble when making this was trying to figure out an algorithm for getting the fewest possible moves for any number of discs and pegs. I soon discovered the Frame–Stewart algorithm, but I couldn't quite figure it out: https://en.wikipedia.org/wiki/Tower_of_Hanoi#Frame%E2%80%93Stewart_algorithm But I also found a 2004 paper by Ben Houston and Hassan Masum called "Explorations in 4-peg Tower of Hanoi", which was very useful to me (see the Minimum Moves Calculator sprite for more about that): http://service.scs.carleton.ca/sites/default/files/tr/TR-04-10.pdf The Mathologer video "The ultimate algorithm" was also very very helpful: https://youtu.be/MbonokcLbNo The sounds are all from the Scratch library, although some are edited beyond recognition.

Project Details

Project ID513313887
CreatedApril 9, 2021
Last ModifiedAugust 24, 2023
SharedApril 14, 2021
Visibilityvisible
CommentsAllowed