Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-04-24 09:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found