Last active
August 29, 2015 14:20
-
-
Save alancnet/dcc6f2394642bfd0a06b 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 sailorDivide pile = | |
let monkeyShare = 1 | |
let preDividePile = pile - monkeyShare | |
let sailorShare = preDividePile / 5 | |
if not (sailorShare * 5 = preDividePile) then -1 | |
else preDividePile - sailorShare | |
let groupDivide pile = | |
let sailorShare = pile / 5 | |
if not (sailorShare * 5 = pile) then -1 | |
else 0 | |
let testSum pile = | |
let result = pile |> sailorDivide |> sailorDivide |> sailorDivide |> sailorDivide |> sailorDivide |> groupDivide | |
result >= 0 | |
let solutions = seq { | |
let i = ref 0 | |
while true do | |
i := i.Value + 1 | |
if testSum i.Value then | |
yield i.Value | |
} | |
[<EntryPoint>] | |
let main argv = | |
let list = | |
solutions | |
|> Seq.take 10 | |
|> Seq.toList | |
printfn "%A" list | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment