September 2, 2009 at 6:45 am
Comments posted to this topic are about the item Monty Hall Paradox
September 9, 2009 at 1:05 pm
(removed)
September 9, 2009 at 3:53 pm
That is an interesting puzzle. Here is another solution using a CTE instead of a loop.
-- Setup
set nocount on
-- Create a table to store the results.
create table Doors
(ID int
,ChosenDoor int
,WinningDoor int
,WinLose as case when ChosenDoor = WinningDoor then 0 else 1 end -- Win = 1, Lose = 0
);
-- Use a CTE to generate 10,000 "contestants" and their chosen/winning doors.
-- If the chosen door equals the winning door the contestant will switch when given the
-- option and lose. Otherwise they will switch to the winning door and win.
with Digits(i)
as (select i
from (select 1 union select 2 union select 3 union select 4 union select 5 union
select 6 union select 7 union select 8 union select 9 union select 0) AS X(i))
insert into Doors(ID, ChosenDoor, WinningDoor)
select (D3.i * 1000 + D2.i * 100 + D1.i * 10 + D0.i) AS seq
,abs(cast(cast(newid() as varbinary) as int)) % 3 + 1 ChosenDoor
,abs(cast(cast(newid() as varbinary) as int)) % 3 + 1 WinningDoor
from Digits as D0, Digits as D1, Digits as D2, Digits as D3
-- Select the total number of winners (1) and losers (0).
selectWinLose
,count(*) Total
from Doors
group by WinLose
-- Clean-up
drop table Doors
set nocount off
September 9, 2009 at 4:07 pm
Very cool alternative. Thanks for sharing! 🙂
November 10, 2014 at 2:23 pm
I think this is bogus. The reason that I think it is bogus is that on the second bet you are excluding the door you picked from your first bet ONLY if it is not the right door. So you are adding new information.
*******************
What I lack in youth, I make up for in immaturity!
November 10, 2014 at 4:42 pm
brosspaxedi (11/10/2014)
I think this is bogus. The reason that I think it is bogus is that on the second bet you are excluding the door you picked from your second bet ONLY if it is not the right door. So you are adding new information.
Thanks for sharing you're wonderful insight.
November 10, 2014 at 4:42 pm
I am surprised anyone even found this old post. LOL.
May 24, 2016 at 6:44 am
Interesting script.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply