FLIPSTER
STEAMpunks WIKI
Join The Parade, New South Wales - Ph:+61-2-1234-5678

Mathematical Thinking Banner


Also see:

Random Coin Tossing Example Activity (Random.org)

Tower of Hanoi/Brahma: (Wikipedia)

The puzzle was invented by the French mathematician Édouard Lucas in 1883.

There is a story about an Indian temple in Kashi Vishwanath which contains a large room with three time-worn posts in it surrounded by 64 golden disks. Brahmin priests, acting out the command of an ancient prophecy, have been moving these disks, in accordance with the immutable rules of the Brahma, since that time. The puzzle is therefore also known as the Tower of Brahma puzzle.

According to the legend, when the last move of the puzzle will be completed, the world will end.[2] It is not clear whether Lucas invented this legend or was inspired by it.

If the legend were true, and if the priests were able to move disks at a rate of one per second, using the smallest number of moves, it would take them 264−1 seconds or roughly 585 billion years[3] or 18,446,744,073,709,551,615 turns to finish, or about 127 times the current age of the sun.

Ian Parberry's Towers of Hanoi

Tower of Hanoi - Algorithm

Here's an iterative solution that's succinct:

#!/bin/sh
/bin/echo -n "Towers of Hanoi. How many disks? "
read disk
for (( x=1; x < (1 << $disk ); x++ )) ; do
  i=$((($x & $x - 1 ) % 3))
  j=$(((($x | $x - 1 ) + 1 ) % 3))
  echo "Move from tower $i to tower $j"
done

When run, this delightfully short script produces the result I desire, a step-by-step solution to the Towers of Hanoi problem.

Mathematical Thinking Quiz links:

 
 
2019/home.txt · Last modified: 07/10/2020/ 11:13 by admin