Crazy Eights

Voice Card  -  Volume 23  -  John Card Number 5  -  Wed, Feb 26, 1992 6:22 PM

Some people read Dear Abby. Some read Miss Manners. But for me, on a lazy Sunday morning when I'm trying to avoid doing anything useful, nothing beats "Ask Marilyn!"

In case any of you never secretly delved into that trashy Parade magazine insert that arrives in most every Sunday paper, Marilyn is none other than Marilyn Vos Savant, the world's smartest person according to the Guiness Book of Records. I don't actually believe that Marilyn is the world's smartest person, in fact I'm not sure if she's even in the upper ten per cent, but I usually get a kick out of reading her column. The column invariably features some backwoods rube who thinks he can "outsmart" Marilyn with a half-baked brain teaser, and another who asks some deep philosphical question. Marilyn picks a question or two out of her mail bag and makes short work of them.

ANYWAY, here is the question from last Sunday's column: "How can you take eight 8s and add, subtract, multiply or divide them to make a total of 1000?"

A charming little puzzle. Roger and I sat around the table and pondered it. It's a familiar problem to me because sometimes, when I can't fall asleep, I make a game out of watching my LED alarm clock. I take a time, say 2:19, and try to make an equation out of it, like 2+1=SQUARE ROOT(9). The rule is that I have to find an equation before the clock flips to the next minute.

But I digress. Marilyn immediately came up with "the" answer, which is 888+88+8+8+8=1000. The question that Roger and I pondered was whether or not this is the ONLY answer, and if so, how could we prove it.

You may want to take a moment or two to ponder the problem with me. Remember, you can only use the four operations of addition, subtraction, multiplication, and division with no parenthesis. The expression should be evaluated in the standard way, from left to right with multiplication and division taking precedence over addition and subtraction. In Marilyn's solution, the 888 could actually land in any of five equivalent positions, and since the 88 could land in any of the remaining four positions, there are 20 permutations of her answer, all essentially the same. The question is, are there any OTHER equations that would satisfy these conditions.

This, clearly, is a job for HyperCard! I won't spoil the fun by revealing the answer, but I will show you one way of finding it. Just create a blank one card stack with a scrollable card field and button. Type the following short script into the button (you may want to expand the text field to see it in all its glory):

on mouseUp
   put "+-*/&" into which
   put "8+8+8+8+8+8+8+8" into exp
   put "1111111" into ops
   repeat 78124 times
      put flip(ops,7) into ops --increment counter
      repeat with j=7 down to 1
         put char j of ops into x
         if char x of which is "&" then
            delete char j*2 of exp
            put char x of which into char j*2 of exp
         end if
      end repeat
      if (value of exp)=1000 then put
      exp&"= 1000"&return after card field 1
      put restore(exp) into exp
   end repeat
end mouseUp

function flip counter,x
   if char x of counter is 5 then
      put 1 into char x of counter
      return flip(counter,x-1)
      add 1 to char x of counter
      return counter
   end if
end flip

function restore x
   get length of x
   repeat with j=it down to 2
      if char (j-1) to j of x is "88" then
      put "&" before char j of x
   end repeat
   return x
end restore

Just push the button and go to bed. When you get up in the morning your answer should be waiting for you. I submit that no other language could solve this problem so elegantly. And what project could be of less apparent redeeming value on a lazy Sunday afternoon?