Towers of Hanoi in Haskell
Umm. What about

import Data.Bits
hanoi :: Int -&gt; [(Int, Int)]
hanoi n = map (\x -&gt; ((x .&amp;. (x-1)) `mod` 3, ((x .|. (x-1)) + 1) `mod` 3)) [1..shift 1 n]
main = print $ hanoi 5


?