Well, the solution is fairly simple, if you can assume the convicts are smart (which is quite bold), and they have a similar sense of "how long it would take to figure out a logic problem".

The solution is that if two convicts wear a black disk, the third convict knows he has a white disk. But from looking at the backs of the other convicts, the convicts know that there is at most one black disk - and if there's a black disk, it's on their back, and the others see a white and a black disk. However, since noone leaves right away, the ones seeing a black and a white disk will conclude their disk must be white - there cannot be two black disk, and they can leave. But this also doesn't happen, so the premises that one's disk is black is false, ergo, everyone has a white disk.

But as I said, there's a timing problem, and the assumption the others are smart. Usually, this question is asked with perfect logican getting hats or disks to wear, and there is some timing mechanism (for instance, each of them is asked a question in a particular order).

I don't really see a way of demonstrating this puzzle in Perl.

Abigail


In reply to Re: Suggestions for writing a Perl application by Abigail-II
in thread Suggestions for writing a Perl application by phax

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.