Skip to content

Instantly share code, notes, and snippets.

@Rembane
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rembane/8814965 to your computer and use it in GitHub Desktop.
Save Rembane/8814965 to your computer and use it in GitHub Desktop.
module Main where
-- This one works, but is terribly slow.
-- Make it faster!!!
step (my, mx) (y, x) = if my == y && mx == x
then 1
else stepY + stepX
where
stepY | y < my = step (my, mx) (y+1, x)
| otherwise = 0
stepX | x < mx = step (my, mx) (y, x+1)
| otherwise = 0
main = do
putStrLn $ show $ zip [1..] $ map (\a -> step (a, a) (0, 0)) [1,2,3,4,5,6,7,8,9,10,11,12]
-- putStrLn $ show $ map (\a -> 2**a) [3,4,5,6,7,8,9,10]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment