Monty Hall problem: Difference between revisions

J: add a small bit of explanation
(alphabetize)
(J: add a small bit of explanation)
Line 965:
 
<lang j>scenario=: ((pick@-.,])pick,pick) bind DOORS</lang>
 
(Here, I have decided that the result will be a list of three door numbers. The first number in that list is the number Monty picks, the second number represents the door the user picked, and the third number represents the door where the car is hidden.)
 
Once we have our simulation test results for the scenario, we need to test if staying would win. In other words we need to test if the user's first choice matches where the car was hidden:
Line 979 ⟶ 981:
320 680</lang>
 
Or, we could bundle this all up as a defined word. Here, the (optional) left argument "names" the doors and the right argument says how many simulations to run:
 
<lang j>simulate=:3 :0
6,962

edits