Recently I began receiving a newsletter for programmers and amateur mathematicians called Algorithm, edited by A. K. Dewdney, the fellow who does Martin Gardner's old column in Scientific American. The first issue contained a charming little puzzle that was ideal for a quick Mr. Wizard stack:
THE AMAZING BUTTONBOARD
"Professor Norgate, the great circuit-theorist, built an amusing digital lock for his office door. It consisted of a small square of plastic, about four inches on a side, studded with a 5 by 5 array of buttons.
"If any button was pushed, the button and its four adjacent neighbors would immediately light up. If one continued to push buttons on Professor Norgate's amazing button board, one would notice that the rule was a little more general than this: pushing a button would actually change its state (lit or unlit) as well as changing the state of its four neighbors.
"Only when all the buttons were lit would the lock on Professor Norgate's door be released. How did Professor Norgate get into his office? What magic sequence of button-pushes gained entry to this inner sanctum?
"Clever readers might notice that it makes no difference what order the buttons are pushed; at the end of the sequence all that matters is which buttons are pushed... There is more than one solution (not counting rotations and reflections)."
For this issue of Mr. Wizard I have created a working model of this buttonboard, complete with a door that opens as soon as all 25 buttons are lit. And of course something mildly niftly happens as soon as you solve the puzzle! Have fun! I'll try to remember to provide a solution next time around for the slower members!
HOW IT WORKS
Frankly, the reason I choose this project was that I was up against the wall and I just didn't have time to create a massive stack. This issue's offering is SO SIMPLE that it could easily be created on your lunch break; it took me less than an hour start to finish (and most of that was spent playing around with sound effects and what-not).
Aside from the trivial Clear and Return to Wizard buttons, this single card stack has only one real script, and that script is quite short. How is this done?
Each of the 25 buttons on the button board has a single word script: "flip". What I did was add a new word to the HyperTalk language, "flip", by creating an "On flip" handler in the card script. This one command handles all the action of the game.
You HyperTalk buffs may want to have a look at this script. Just summon the menubar, select "Card Info" from the Objects menu, and push the Script button. If you can't solve the puzzle you can cheat by hotwiring the board: make a minor change to the script of the clear button and then push any one of the 25 buttons off and on again. What kind of minor change, you ask? I'll leave that up to you. Enjoy!