Monty Hall problem: Difference between revisions
Content added Content deleted
(Go solution) |
No edit summary |
||
Line 192: | Line 192: | ||
New random choice: 50.17% |
New random choice: 50.17% |
||
</pre> |
</pre> |
||
=={{header|APL}}== |
|||
<lang apl> |
|||
∇ Run runs;doors;i;chosen;cars;goats;swap;stay;ix;prices |
|||
[1] ⍝0: Monthy Hall problem |
|||
[2] ⍝1: http://rosettacode.org/wiki/Monty_Hall_problem |
|||
[3] |
|||
[4] (⎕IO ⎕ML)←0 1 |
|||
[5] prices←0 0 1 ⍝ 0=Goat, 1=Car |
|||
[6] |
|||
[7] ix←⊃,/{3?3}¨⍳runs ⍝ random indexes of doors (placement of car) |
|||
[8] doors←(runs 3)⍴prices[ix] ⍝ matrix of doors |
|||
[9] stay←+⌿doors[;?3] ⍝ chose randomly one door - is it a car? |
|||
[10] swap←runs-stay ⍝ If not, then the other one is! |
|||
[11] |
|||
[12] ⎕←'Swap: ',(2⍕100×(swap÷runs)),'% it''s a car' |
|||
[13] ⎕←'Stay: ',(2⍕100×(stay÷runs)),'% it''s a car' |
|||
∇ |
|||
</lang> |
|||
<pre> |
|||
Run 100000 |
|||
Swap: 66.54% it's a car |
|||
Stay: 33.46% it's a car |
|||
</pre> |
|||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |
||
<lang ahk> |
<lang ahk> |