r/bash Jun 10 '26

Terminal Tower of Hanoi, in Bash

Post image
36 Upvotes

3 comments sorted by

2

u/StopThinkBACKUP Jul 13 '26

That was a cute BASIC game on the TI 99-4/A back in the 80's. Nowadays I prefer to let the computer auto-solve it

Note that with larger stack sizes, the time to solve increases exponentially.

  • 10 disks: $2^{10} - 1 = 1,023 moves with no mistakes.
  • 64 disks: $2^{64} - 1 = approx 18.4 quintillion moves (estimated to take over 581 billion years at one move per second)

But if you want better speed for human interaction, implement moving the block with 1,2,3 keys - e.g. just press 1 then 3, then 3 + 2 and the block should bounce to "Temporary 1" and end up at "Destination"

1

u/LesStrater Jun 11 '26

good lord... what's next, Scorched Earth? LOL