Mailing List Archive: 49091 messages

## [REBOL] A Rebol Challenge. The Monty Hall Puzzle

### From: reichart::prolific::com at: 15-Dec-2001 23:47

```
We Reboler have been challenged.

I was posing some puzzles with some friends on another mailing list I belong
to, the enjoyment of which is provided here first should you want to try and
solve this for yourself.  However, one of the people responding was a
programmer, and he wrote a program to try to solve the problem.  First he
wrote this in Pearl (183 characters), then in Matlab (136 characters).  I
put it to you--smarter people than I--to put this man to shame!  Give me
your best Rebolette, and I will make him see the error of his ways :-)

OK, no looking this up on the web.  This is a real fun one if you have not
seen it before, or better stated, worked through it.

The scenario is such: you are given the opportunity to select one closed
door of three, behind one of which there is a prize. The other two doors
hide "goats" (or some other such "non-prize"), or nothing at all. Once you
have made your selection, Monty Hall will open one of the remaining doors,
revealing that it does not contain the prize. He then asks you if you would
like to switch your selection to the other unopened door, or stay with your
original choice. Here is the problem:

Does it matter if you switch?

P.S. this problem was presented to two of my engineers and myself many many
years ago.  We were told that the "staff" scientist at the company of the
presenter all got it wrong.  So the three of us worked on it together for
about 25 minutes.  Came to our conclusion, then wrote a computer program to
prove it.
I then wrote a layman's description of "why." Which I found was
needed because SO MANY PEOPLE CAN NOT ACCEPT THE ANSWER.  Especially
statisticians!  Too funny.  If anyone wants a copy, I will dig it up.

Now for the Email from my friend:

He writes...

Nah, matlab is the way to go for this:

b=sum(floor(3*rand(100,100))==0);y=floor(3*rand(100,100));
o=(floor(2*rand(100,100))+1).*(y==0)+(3-y).*(y>0);c=sum(y.*o>0);
d=sum(c>b-c<b); [b;c]
if (d>90) fprintf(1,"Switching is better (95%%+ confidence)\n"); end

But maybe you can do better in Rebol.  I don't see a way to off the top of
my head.  Note that if we're just comparing the core computation, the matlab
is barely three lines.  (The "o" variable is not strictly needed, but I am
including it anyway to explicitly construct the
door-picked-by-Monty.)

Perl is 183 characters, not counting invocation from the command line or