Created
August 30, 2012 04:13
-
-
Save 2GMon/3522254 to your computer and use it in GitHub Desktop.
Project Euler : Problem 39
This file contains hidden or 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
-- 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