Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: A Rebol Challenge. The Monty Hall Puzzle IN 0 BY TES

From: brett:codeconscious at: 20-Dec-2001 10:46

Hi Reichart, Thanks for the compliment, I have to "fess up" though must last posted solution (the verbose one) has a bug. Found it last night just after I sent it to a friend to try to convince him of the 2/3 result. :-/ The problem was that the switch strategy was not always assured. Strangely the result is close to 2/3 for the bugged version. Anyway the new (longer) version, attached below, fixes the problem by simulating Monty's part more closely. I have spent an amazing amout of time on this Monty Hall problem and I'm currently trying to convince two of my good friends of the result. And yes one is a statistician. I'm not sure whether to curse you for the amount of time I've had to allocate on the problem or thank you for the stimulating thinking and useful techniques it has produced. :) REBOL [] box: [Box1 Box2 Box3] wins: 0 loop number-of-games: 100 [ pick-a: func [what] [copy/part random what 1] prize: pick-a box choice1: pick-a box montys-choices: exclude box union prize choice1 opened-box: pick-a montys-choices choice2: exclude box union choice1 opened-box if win: equal? prize choice2 [ wins: wins + 1 ] print join "I choose " [ choice1 ". " opened-box " opened. I switch to " choice2 ". Prize in " prize ". I " either win ["win"] ["lose"] "." ] ] print wins / number-of-games Brett.