Anonymous user
100 prisoners: Difference between revisions
F# "smartChoice" modified to use functional approach (though less efficient)
(Add F# version solution for 100 prisoners task) |
(F# "smartChoice" modified to use functional approach (though less efficient)) |
||
Line 2,136:
// strategy optimizing drawer opening
let smartChoice max prisoner (drawers' : int array) =
|> Seq.unfold (fun selection ->
let card = drawers'.[selection-1]
Some (card, card))
|> Seq.take max
|> Seq.contains prisoner
▲ inner 1 prisoner
let smartChoices (drawers' : int array) =
seq { 1..100 }
|