All,
I just came across a game called Bagels. Even though there are 648 possible starting numbers with those rules, you can come up with a strategy that will determine the solution without too many guesses. Having worked out such a strategy, I wondered if it was optimal. It is Friday after lunch and my brain has checked out for the weekend so I figured I would ask you monks and have a little fun in the process.

That means I am changing the rules.

So your challenge is to devise a strategy that, given the input conditions (number of positions and maximum possible value), produces a solution with the optimal number of guesses. Here is an example:

perl bagel_solver.pl p=4 v=14 s=1ACE
p is for the number of positions. v is for the maximum value 14 = 0-9, A, B, C, D, E. s is for the solution. The program will obviously play alone and not interactively.

Given the new rules, I am not sure if my strategy will still work so I post some time this weekend after I have had a chance to think about it. Until then, enjoy those bagels.

See also Mastermind.

Update: In the CB, MidLifeXis has pointed out that I have left a lot to be desired in how to choose a winner (scoring solutions) as well as restricting the input to command line arguments making a test harness prohibitive. I will be offline for much of the weekend and MidLifeXis has graciously agreed to take over explaining how those issues will be resolved :-)

Cheers - L~R


In reply to Challenge: Optimal Bagels Strategy 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.