main.hs 324 B

1234567891011
  1. triplets = foldl1 (++) $ map triplets1 [1..499]
  2. where triplets1 x = foldl1 (++) $ map triplets2 [x+1..999-x]
  3. where triplets2 y = [(x,y,1000-x-y)]
  4. theTripet = filter (\(a,b,c) -> a^2 + b^2 == c^2) triplets
  5. tripletProduct (a,b,c) = a * b * c
  6. main = do
  7. putStrLn $ show $ tripletProduct $ head theTripet