Here's one way to answer it: make the problem more general. Ask for a program that will find the least number of weighings to find the odd ball among n, where n is given as a parameter.

Now I suspect the answer can be reduced to a simple formula, in which case someone might derive the formula and write a program to calculate only that.

If that doesn't fall within the parameters of what you're looking for, you will then need to specify much more clearly what you do and don't want to allow.

I suspect the purpose is to show different people's approaches to solving this sort of thing, and I (and I suspect many of the people that would be interested in this sort of puzzle) would always start off with: "the simplistic approach is to traverse the entire search space, but combinatorial explosion will scupper that pretty quickly; so let's sit down with pencil and paper and see what logic or maths I can apply to reduce that search space". With this approach, finding a formula is an ideal solution: it reduces the search space to one, and so if I found such a formula I'd post just that instead of writing the program at all.

Of course if no-one knows (or can find) a formula, this secondary issue might not arise.

Hugo


In reply to Re^11: Odd Ball Challenge by hv
in thread Odd Ball Challenge by Limbic~Region

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.