|laziness, impatience, and hubris|
Holiday parcel puzzleby cavac (Chaplain)
|on Dec 22, 2011 at 17:42 UTC||Need Help??|
PerlMonks Santa (or s/Santa/friend of yours/g on PM, depending on your religious views) has given you a challenge:
You have three (3) nicely wrapped up parcels in front of you. They look, smell, weigh etc. exactly the same. Except two hold a blank scrap of paper, one of them holds a coupon for 1000XP and instant sainthood on PerlMonks (thats the one you desired for years!).
But given that you can only select ONE of the parcels at random, your changes of gratification are slim.
You select one. Then Santa removes one of the other ones. He also promises you that the one he removed was in fact one of the empty ones. You have now the chance to either stick to the one you selected or switch to the remaining one still on the table (giving the one you currently hold back to Santa).
How are your chances if you stick to the parcel you selected at the start? How are your chances if you switch to the one Santa has left on the table?
Take an educated guess and write it down.
Now, write two scripts, one where you stick to your initial decision, one where you switch. Loop a sufficient number of times (say 10000) to get some statistical significance. Did your guesses match your expectation? So, if you encounter this challenge in real life, what would be the best strategy?
Ok, here's the scripts, statistical results and the answer i came up with:
I hope this little holiday themed puzzle was enjoyable.
BREW /very/strong/coffee HTTP/1.1 Host: goodmorning.example.com 418 I'm a teapot