Skip to content

Instantly share code, notes, and snippets.

@lethain
Created July 24, 2016 02:11
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 lethain/5fc1946f2b6bcbb20e8f63ce1094c95a to your computer and use it in GitHub Desktop.
Save lethain/5fc1946f2b6bcbb20e8f63ce1094c95a to your computer and use it in GitHub Desktop.
module Main (main) where
col :: Int -> [Int] -> [Int]
col 1 acc = acc
col n acc | n `mod` 2 == 0 = col (n `div` 2) (n:acc)
| otherwise = col (3 * n + 1) (n:acc)
opts :: Int -> [(Int, Int)]
opts n = [(length(col x []), x) | x <- [1..n]]
main = do print (snd $ maximum $ opts 1000000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment