#### Problem

*If p is the perimeter of a right angle triangle with integral length sides, {a,b,c}, there are exactly three solutions for p = 120.*

*{20,48,52}, {24,45,51}, {30,40,50}*

*For which value of p <= 1000, is the number of solutions maximised?*

#### Solution

// define function to find the number of solutions for p
let countSolutions p =
[4*p/10..6*p/10]
|> List.filter (fun c ->
[1..p]
|> Seq.takeWhile (fun b -> b + c < p)
|> Seq.exists (fun b -> (pown (p-b-c) 2 + pown b 2) = pown c 2))
|> List.length
let answer = [1..1000] |> List.maxBy countSolutions