Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
15
Task/Monty-Hall-problem/APL/monty-hall-problem.apl
Normal file
15
Task/Monty-Hall-problem/APL/monty-hall-problem.apl
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
∇ 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'
|
||||
∇
|
||||
Loading…
Add table
Add a link
Reference in a new issue