Return to Snippet

Revision: 48646
at July 7, 2011 01:45 by rtperson


Initial Code
import Data.Bits

hanoiBits :: Int -> [(Int, Int)]
hanoiBits n = init $ map (\x -> ((x .&. (x-1)) `mod` 3, ((x .|. (x-1)) + 1) `mod` 3)) [1..shift 1 n]

Initial URL
http://codereview.stackexchange.com/questions/1684/towers-of-hanoi-in-haskell

Initial Description
Credit where it's due: I got this from udpn over at codereview.stackexchange.com. I'm just putting it here for further study.

Initial Title
Towers of Hanoi by Bit Twiddling

Initial Tags


Initial Language
Haskell