Created
October 18, 2012 03:55
-
-
Save miklund/3909788 to your computer and use it in GitHub Desktop.
F# solution to Project Euler 31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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