Monty Hall problem: Difference between revisions
Content added Content deleted
(→{{header|bash}}: Marked incorrect as you need to add the comparison of the two strategies of the player to the simulation.) |
|||
Line 318:
=={{header|bash}}==
{{works with|bash|2.x| and most bash-compatible unix shells}}
<lang bash>
Line 387 ⟶ 386:
current_round=$[$current_round+1]
done
# Changed this summary message to indicate "always stay" vs. "always switch"
echo
echo "Wins
echo "Losses (stick to first choice): $num_lose"
exit 0
</lang>
Line 407 ⟶ 409:
Player chooses #2. Host opens #3 (prize is behind #1) Switch from 2 to 1: WIN.
Wins
Losses (stick to first choice): 4
$ ./monty_hall_problem.sh 10 5
Line 418 ⟶ 422:
Player chooses #5. Host opens all except #7 and #5. (prize is behind #7) Switch from 5 to 7: WIN.
Wins
Losses (stick to first choice): 1
$ ./monty_hall_problem.sh 3 1000
Line 433 ⟶ 439:
Player chooses #3. Host opens #1 (prize is behind #2) Switch from 3 to 2: WIN.
Wins
Losses (stick to first choice): 345
</pre>
|