Created
April 19, 2017 07:17
-
-
Save cboudereau/d279f2b2963ae309209a7938a42af687 to your computer and use it in GitHub Desktop.
This file contains 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
let score = | |
let score x y z = | |
if x = 10 || x + y = 10 then x + y + z | |
else x + y | |
List.fold | |
<| fun s v -> | |
match v, s with | |
| z, (r, [x;y]) -> (r + score x y z), [y;z] | |
| y, (r, x::tail) -> r, x::y::tail | |
| x, (r, []) -> r, [x] | |
<| (0, []) | |
>> fst | |
let strike = 10 | |
[strike;strike;strike] |> score = 30 | |
[strike;strike;strike;strike] |> score = 60 | |
[strike;strike;strike;strike;strike] |> score = 90 | |
[strike;strike;strike;strike;strike;strike] |> score = 120 | |
[strike;strike;strike;strike;strike;strike;strike] |> score = 150 | |
[for i = 1 to 12 do yield strike] |> score = 300 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment