Anonymous user
Monty Hall problem: Difference between revisions
→{{header|Ruby}}
m (→version 2: added a comment regarding the door values (goat or car). -- ~~~~) |
|||
Line 2,740:
#the doors reveal 2 goats and a car
doors = [ :goat
#random guess
Line 2,749 ⟶ 2,748:
begin shown = rand(3) end while shown == guess || doors[shown] == :car
stay += 1
else
#switching guesses wins if the unshown door is the car
switch += 1
end
end
Line 2,762 ⟶ 2,763:
<pre>Staying wins 33.84% of the time.
Switching wins 66.16% of the time.</pre>
=={{header|Run BASIC}}==
<lang runbasic>' adapted from BASIC solution
|