I had an odd dream last night which I attribute to a combination of my recent viewing of the movie WarGames, and some others issues that I should discuss with a therapist.

In my dream I was trapped in a room in which the door would only open when the correct "code" word was spoken. I was provided a large book which was much like a dictionary, minus the definitions. So in my dream I began on page 1 of the book and began reading the words aloud but of course woke before "hitting" the correct one.

When I woke I of course wished I could have utilized Perl in my dream, which led to a more in depth analysis of the issue. I've since been contemplating what the best method would be to obtain the correct word in the shortest amount of time.

For example, if I start at the beginning of the list with the "A"'s and continue reading sequentially this method would work great if the "code word" was towards the beginning of the alphabet but would be horrible if the "code word" was "Zebra".

But are the overall odds the same of getting the correct word by randomly choosing from the list and by reading sequentially? Or would a "slope" of sorts that merges the two methods prove best?

For example, if you start from the beginning of the list and also the end, for example alternating A and Z words:

$guess_1... =~ /\AA/i; $guess_2... =~ /\AZ/i;
Where ultimately $guess_1 would be N+1 and $guess_2 would be N-1.

This method would provide the correct word fastest if it was located at the beginning or the end of the list. But what if the word was in the "M"'s?

So I thought about a function that returned a random word from the subset between the index's of $guess_1 and $guess_2:

$guess_1 < $guess_3 < $guess_2

So now we're left with a loop that try's $guess_1, $guess_2, $guess_3...$guess_1, $guess_2, $guess_3...

Any Math majors out there that can support || destroy my reasoning?

-Nitrox


In reply to Dreams of Probability by Nitrox

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.