# Project Euler Problem 4

Project Euler Problem 4 can be solved using the following steps of our solve approach:

- Sequence of all possible products of 3-digit numbers can be produced by making a cartesian product of all 3-digit numbers, where instead of two numbers their product is placed into the collection; then duplicates are excluded
**PassAll**is used for**select****filter**passes only those sequence members that are palindromic**aggregator**finds the maximal of such

open System let allProducts l1 l2 = List.map (fun x -> (List.map (fun y -> x * y) l2)) l1 |> List.concat let isAnagram (s: string) = new String(s.ToCharArray() |> Array.rev) = s let isPalindromic n = isAnagram(string n) let problem004 () = allProducts [100..999] [100..999] |> Seq.distinct |> solve PassAll isPalindromic Seq.max

Or, without **solve** function the definition of **problem004()** would be

let problem004 () = allProducts [100..999] [100..999] |> (Seq.distinct >> Seq.filter isPalindromic >> Seq.max)

Advertisements

## Trackbacks & Pingbacks