November 11, 2007

Re-jumble

Filed under: Puzzles, Computing — mark @ 4:03 pm

Much to the chagrin of my teen-age daughter, I’ve been looking at FaceBook and trying to learn a little bit of how their applications platform works. For that I created a FaceBook Jumble application from the page found on this site.

In doing that I had the first chance in a long time to clean up the code, so I also modified the Renaissance version in two ways. First, I improved the output display, and second, I put it back in its own page. The experiment of putting it in a WordPress blog page made no difference in the page rankings and was a little brittle anyway. I had to use runPHP to make it work inside of WordPress, and that would get shut down anytime someone entered a comment for reasons I could never fathom.

April 29, 2007

Hidden Meaning

Filed under: Books, Puzzles — mark @ 3:40 pm

One of the side-effects of working on any genre of puzzle is that you can put your head into a kind of overdrive on whatever neurons are firing to solve those puzzles. When I was in high school and living with my Dad, we went through a ‘jigsaw puzzle’ period, when there was always some 3,000 piece monster slowly coming together on the dining room table. I got so I would see jigsaw puzzle-piece patterns in everything. Carpets, wallpaper, piles of sand … anything.

I’ve lately been working on the Jumble puzzle to move it into the blog, and again (it ain’t the first time) got into that mode. I woke up at 4AM today with the inspiration that “Albus Dumbledore” is a jumbled version of “A Doubled Slumber”. Hmmm. As I woke up (I’ve been watching zombie movies lately, so going back to sleep isn’t really an option), the letters slid around to “Double Subdermal”.

So call it what you will, but I place great stock in these Jungian inspirations from the subconscious. This confirms my suspicion that we will learn in this final Summer of Harry Potter, that the good wizard is not dead, but like Merlin, simply sleeps again.

April 28, 2007

Jumble Stats and runPHP

Filed under: Puzzles, Web Tools — mark @ 7:03 am

Very few people read this blog, or at least, few read and then link to it, which has caused my blog ranking to drop from the low 100,000s to the point where it is now crowding 2,000,000. But my server logs indicate that the site itself is fairly popular, particularly among those looking for one of the puzzle solvers (see sidebar).

To get the blog stats to reflect the reality would mean incorporating the solvers into the blog itself … right now they are mostly standalone PHP applications. But that causes a problem, since WordPress software is itself a PHP application and does not look kindly on interlopers once it is running. But WordPress also supports an army of plugins that can be installed to add blog functionality, and among these I found James van Lommel’s runPHP plugin for WordPress, which allows integration of PHP code into a Post or static blog Page.

So at the top of the page you will now see a tab for the “Jumble” solver, which has now been blogified using runPHP. After a few hassles fixing my crummy database scripting (I think it was my very first attempt at PHP, so I make allowances), the script ran without modification.

So give it a try, and feel free to link to the Jumble page or this post (hint, hint)! Let’s get those blog stats out of the woods of obscurity and back to the comfortable region of the barely known.

December 19, 2006

Innumerate Insight

Filed under: Puzzles — mark @ 9:30 pm

… or following up to the last post, maybe this is ‘Et Three Brute’.

My niece came home with her own fifth grade math challenge: For what four-digit number EFGH can it be said EFGH x 4 = HGFE

My sister-in-law was annoyed by this, because by the time I saw it, the problem had stumped my niece and every adult in the room. She observed that a puzzle like this, sprung on a kid unawares too early can cause them to lose confidence in their own mathematical creativity. I think she’s right. She also said that she was going to tell her daughter to just say all the digits were zero and skip the problem.

She’s smarter than she lets on … 0000 is one of the two correct answers! (The degenerate answer, snooty math majors would say, suggesting that the format of the problem indicates E, F, G, and H are different numbers. But the problem doesn’t say that.)

I’m terrible at these, but gave it a shot. All multiples of 4 end with either 0, 2, 4, 6 or 8. Surveying that bunch, it seemed likely that we were looking at 2 thousand something times 4 would be 8 thousand something, so we’d get:

2FG8 x 4 = 8GF2

I figured it out from there through trial and error, but should have asked Dad. He pointed out that F had to be less than 3 (2300 x 4 would be 9200 … too big). That leaves 2, 1, and 0, and we are already using 2, so it’s 1 or 0. “And”, he says, “it can’t be zero, because any number ending ‘02′ divided by 4 would have a remainder of 1/2." Oh yeah. That leaves 1.

So we have 21G8 x 4 = 8G12.

Using simple algebra 4 * (2108 + 10 * G) = 8012 + 100 * G, so

8432 + 40 * G = 8012 + 100 * G

420 = 60 * G, or G = 7

2178 * 4 = 8712

… and for anyone still paying attention, note that we left fifth grade math quite some time ago!

In 60 seconds you can write a Perl script:

#!/usr/bin/perl -w
use strict;

my $i;
my ($s, $t);

for ($i = 0;$i < 10000;$i++) {
    $s = sprintf("%04d",$i);
    $t = reverse($s);

    if (($s * 4) == $t) {
        print "$s * 4 = $t\n";
    }
}

… that in a fraction of a second tells you:

0000 * 4 = 0000
2178 * 4 = 8712

December 12, 2006

Et tu, Brute?

Filed under: Puzzles — mark @ 9:07 pm

Jake came home from fourth-grade math today with a certified Math Challenge: using the integers 1 to 9 only once each, find how many true sets of 3-digit numbers x, y, and z will satisfy the equation x + y = z.

The example given was 237 + 654 = 891. And we are told there are over 300 solutions.

God knows there must be an elegant mathematical approach to this, but man, there is a Science Quiz breathing down our neck for Friday, there are writing exercises to complete, and that Star Wars book isn’t going to read itself.

In short, it’s a perfect time to employ our friend, Brute Force.

After installing the perl module List-Permutor, we dash off the following script:

#!/usr/bin/perl -w
use List::Permutor;

my $perm;
my ($a, $b, $c);
my @set;
my $ctr = 0;

$perm = new List::Permutor qw/ 1 2 3 4 5 6 7 8 9 /;

while (@set = $perm->next) {
    $a = $set[0] . $set[1] . $set[2];
    $b = $set[3] . $set[4] . $set[5];
    $c = $set[6] . $set[7] . $set[8];

    if (($a + $b) == $c) {
        $ctr++;
        printf "%-3d: ", $ctr;
        print "$a + $b = $c\n";
    }
}

That’s right … generate every one of the 9! = 9*8*7*6*5*4*3*2*1 = 362,880 permutations of the characters 123456789, carve off the first three digits of each permutation to be x, the second three to be y, the third 3 to be z, and see if x + y = z. If it does, count the solution and print. There are 336 solutions (listed here).

Of course, while I was screwing around with this, Jake found two on his own … against staggering odds. That kid needs to be buying more scratch tickets.

So we have to go with his answer … besides, I don’t think they cover Perl until next term, so this would be difficult to explain.

Next Page »