Created
July 24, 2016 02:11
-
-
Save lethain/5fc1946f2b6bcbb20e8f63ce1094c95a to your computer and use it in GitHub Desktop.
Simple solution to https://projecteuler.net/problem=14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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