Skip to content

Instantly share code, notes, and snippets.

@alancnet
Last active August 29, 2015 14:20
Show Gist options
  • Save alancnet/dcc6f2394642bfd0a06b to your computer and use it in GitHub Desktop.
Save alancnet/dcc6f2394642bfd0a06b to your computer and use it in GitHub Desktop.
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