Skip to content

Instantly share code, notes, and snippets.

@miklund
Created October 18, 2012 03:55
Show Gist options
  • Save miklund/3909788 to your computer and use it in GitHub Desktop.
Save miklund/3909788 to your computer and use it in GitHub Desktop.
F# solution to Project Euler 31
module PE31
let solution n =
let filter_less_than n = List.filter (fun c -> c <= n)
let rec _solution values = function
| 200 -> 1 // success
| n when n > 200 -> 0
| n -> List.sum (List.map (fun coin -> _solution (values |> filter_less_than coin) (n + coin)) values)
_solution [200; 100; 50; 20; 10; 5; 2; 1] n
// run
solution 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment