module Problem39 where

import Data.Ord
import Data.List

main :: IO ()
main =
    print
        . fst
        . maximumBy (comparing snd)
        $ [ (n, pythagoreasSolutions n) | n <- [1 .. 1000] ]

pythagoreasSolutions :: Int -> Int
pythagoreasSolutions s = length
    [ True
    | a <- [1 .. s - 1]
    , b <- [1 .. a]
    , a + b < s
    , a * a + b * b == (s - a - b) * (s - a - b)
    ]
