## Thursday, January 29, 2009

### Waldo's Been Found In The PI

Hey There,

Last Friday, we posted a little puzzle we made up entitled "Where's Waldo?" where the objective was to find Waldo amongst the first million digits to the right side of the decimal point in the irrational number PI. Apologies for the picture as my editor couldn't deal with the length of the line and insisted on chopping it up into bits. The numbers were in order, so all that was necessary to get the entire string without spaces was doing simple deletion of all the space characters.

Of course, there was only supposed to be one answer, but, if you're among the many who found Waldo all over the place, I guess we can count that, too. Although I wasn't specific, I assumed a knowledge of Waldo that wasn't shared by everyone (He's a goofy bastard that likes to hide in large crowds of people wearing a silly hat ;) No matter. For instance, many folks posited that any number could represent Waldo (just as a picture - a singular thing - of a cat could represent the three letters C, A and T). This is logically valid, and those of you who took that position are probably still laid out by Waldo-overload ;)

Also (closer to our solution) it was suggested that any 5 consecutive-and-unique numbers could represent Waldo. This is also true.

However, and this is why we put the puzzle up (because we figured this out by accident and it seemed kind of cool) there is a way to determine the "ONE" Waldo that's hiding in those million digits.

WARNING: If any of the above put you off and you want to go find the "ONE" Waldo on your own, please stop reading now, because this post will ruin it for you ;)

Here's how we found the "ONE" Waldo:

a. First, we tried the really simple stuff that was guaranteed to fail, but tested just to make sure that it did, anyway. And, we're happy to report that it all did :)

For instance(s):
i. Waldo, in binary, with a capital W (0101011101100001011011000110010001101111) and a lowercase w (0111011101100001011011000110010001101111) doesn't show up anywhere in the sequence.

ii. Waldo, in decimal converted from binary, with a capital W (8797108100111) and a lowercase w (11997108100111) doesn't show up either.

iii. Waldo, in simple a=1, b=2, etc, code (where case doesn't matter and both Waldo's are 23112416) doesn't exist within the million digits either. I actually thought that one might be there.

b. Then we went for the answer that ended up exposing where the "ONE" Waldo was. To tell you the truth, we didn't expect to find him, so this spur-of-the-moment puzzle was probably just as much fun (or just as irritating) for us as it was for you ;)

i. As above, the assumption was that Waldo had to belong to a group of 5 digits that included no duplicates, since there are no duplicate letters in Waldo's name.

ii. In order to find all of these possible combinations within the million digits we employed an expanded routine based on a previous post we did on finding overlapping matches using Perl lookahead assertions to run through all 5-digit combinations in the million numbers, looping through those to find all the ones that only appeared once in the million-digit chain and then, from that subset, only keeping those that didn't contain any duplicate digits (I put all the digits into a one line file called "pi"), resulting in the following suspects (The command line's ugly... I know ;)

`host # perl -e 'open(PI, "<pi");\$variable = <PI>; @variable = \$variable =~ /\d(?=(\d\d\d\d\d))/g;for \$var (@variable) {\$matches{\$var}++;};while ((\$key,\$value) = each %matches) { if ( \$value == 1 ) { \$key =~ tr/0-9/0-9/s;if ( length(\$key) == 5 ) {print "\$key => \$value\n"} } };'27315 => 104937 => 175138 => 192758 => 187329 => 176923 => 104504 => 169768 => 167482 => 140212 => 110686 => 135052 => 115320 => 195485 => 150134 => 174839 => 191867 => 172382 => 131640 => 175205 => 197823 => 163502 => 129090 => 123291 => 185476 => 126323 => 132013 => 101456 => 194357 => 196874 => 163160 => 191493 => 153268 => 191926 => 157521 => 136748 => 109074 => 181764 => 1`

iii. Then, to find the "ONE" Waldo, we just augmented the previous Perl command line program to ensure that it met the following simple specifications: Based on simple case-insensitive alphabet-numeral code (a=1 .. z=26), the numbers had to appear in an order that would satisfy the name "Waldo" (e.g. W had to be greater than a, l, d and o, etc), which broke down to this simple table (actually listed above as one of the numeral sequences that couldn't be found... of course, it changes after we're done here, since we're applying the relative weight of each letter, rather than assigning each a specific numeric value):

`W a l d o = 23 1 12 4 16`

using this template, the "ONE" number from the list above would have to satisfy the relative-weight differences between all 5 letters/numerals

`Name:     W  a  l  d  oPos:      0  1  2  3  4Weight:   23 1 12  4 16`

in short, in the "ONE" correct 5-digit string, in subsequent order, the first digit would have to be greater than the fifth, which would have to be greater than the third, which would have to be greater than the forth, which would have to be greater than the second.

If you'll pardon the monstrous code, the command line Perl used to find "Waldo" follows:

`host # perl -e 'open(PI, "<pi");\$variable = <PI>; @variable = \$variable =~ /\d(?=(\d\d\d\d\d))/g;for \$var (@variable) {\$matches{\$var}++;};while ((\$key,\$value) = each %matches) { if ( \$value == 1 ) { \$key =~ tr/0-9/0-9/s; @key = split(//, \$key);if ( length(\$key) == 5 && ( \$key > \$key ) && ( \$key > \$key ) && ( \$key > \$key ) && ( \$key > \$key )) {print "\$key => \$value\n"} } };'92758 => 1`

leaving us with our answer: 92758. Below are the original list of million digits and the same list with "Waldo" in bold red font (hyperlinked to an offsite location for the actual million digit lists through pictures of parts of them).

Hope you enjoyed the challenge. Everyone who gave this some thought won, even if they didn't reach the same conclusion as we did :) And if you did find another way to reach "one" conclusion, please email us and let us know. We'd love to post the alternative answer!

Cheers,

Where's Waldo? There's Waldo! , Mike

Discover the Free Ebook that shows you how to make 100% commissions on ClickBank!

Please note that this blog accepts comments via email only. See our Mission And Policy Statement for further details.