http://qs1969.pair.com?node_id=220552

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