Skip to content

Instantly share code, notes, and snippets.

@2GMon
Created August 30, 2012 04:13
Show Gist options
  • Save 2GMon/3522254 to your computer and use it in GitHub Desktop.
Save 2GMon/3522254 to your computer and use it in GitHub Desktop.
Project Euler : Problem 39
-- Project Euler : Problem 39
import Data.List
rectTriangle :: Int -> [Int]
rectTriangle n = [a + b + c | a <- [1..(n - 2)], b <- [1..(a - 1)],
c <- [1..(b-1)], a^2 == b^2 + c^2,
a + b + c <= n]
main = print $ snd $ maximum $ map (\x -> (length x, head x)) $ group $
sort $ rectTriangle 1000
-- 840
-- ./dailycoding39 187.38s user 0.47s system 99% cpu 3:08.78 total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment