About two years ago, Veritasium posted The Riddle That Seems Impossible Even If You Know The Answer on Youtube. Today i was rewatching that video, because after seeing it initially i had some doubts, and it was a bit of an itch i finally decided to scratch.

The basic riddle goes something like this (watch the video for a much more coherent explanation AND the solution):

  1. You have 100 prisoners, each with a number.
  2. There is a room with 100 (numbered) boxes, and every prisoner number is in one random box.
  3. Prisoners enter the room one by one
  4. Each prisoner can open 50 boxes and search for their prisoner number.
  5. Each prisoner has to leave the room exactly as he found it.
  6. If ALL prisoners find their own number, everyone goes free.
  7. If even a single prisoner fails to finds his number, everyone stays in jail.
  8. Prisoners can decide on a tactic BEFORE the event, but can't communicate in any way DURIN the event.

If prisoners just do random sampling, their chances are 0.5**100 = 0.0000000000000000000000000000008.

Is there a better tactic? (Rest of the post in spoiler tags if you want to have a go on the problem yourself).

Frankly, even having programmed a full simulation of the solution myself, it still absolutely boggles my mind that this actually works at all. Maths is weird.

PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP
Also check out my sisters artwork and my weekly webcomics

In reply to Proving Veritasiums riddle using Perl by cavac

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.