Skip to content

Instantly share code, notes, and snippets.

@jvrmaia
Created July 14, 2012 18:02
Show Gist options
  • Save jvrmaia/3112386 to your computer and use it in GitHub Desktop.
Save jvrmaia/3112386 to your computer and use it in GitHub Desktop.
Torre de Hanoi em Haskell
hanoi :: Int -> a -> a -> a -> [(a,a)]
hanoi 1 x y z = [(x,y)]
hanoi n x y z = hanoi (n-1) x y z ++ hanoi 1 x z y ++ hanoi (n-1) y z x
tamhanoi :: Int -> Int
tamhanoi n = 2^n - 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment