Being just 5 and a half, Leo isn’t quite up to algebra yet, but I’m getting him used to relatively complex equations. He also loves treasure hunts, cryptography, and the periodic table. So, I figure, why not put ’em all in the same game!

This is going to take some explanation. Let’s start with the treasure hunt and the periodic table. Here’s a clue: “THE HELIUM IS IN THE OVEN”

And here you go:

This is a card from this great deck of element “trading cards” by Theodore Gray:

Okay, so you can imagine a bunch of those hidden around the house. Now, let’s add a little cryptography. Easy enough, just encode “HELIUM IS IN THE OVEN”. I could use any old code — Leo knows a bunch of simple ones — but, hey, why not throw in a little math while we’re piling on.

This takes a little explaining…

First, assign a letter starting from A to each letter in the message:

“the helium is in the oven”
becomes:
ABC BCDEFG EH EI ABC JKCI

We want to learn that A=20 (t), B=8 (h), C=5 (e), and so on. But why give it away so easily when Leo’s willing to work for it. Instead make a mathematical game out of it:

A=20
B=8
C=(A*Helium)/B
D=(B-C)+Fluorine
E=(D/Lithium)+C
F=(D-E)*Nitrogen
G=13
H=19
I=(H-G)+Oxygen
J=(H-I)*Lithium
K=(I+J)-Nitrogen

The first two are always given, and the rest follow, using each previous pair as inputs. The element names become their atomic numbers, and when I can’t find a simple equation that creates the number I’m looking for, I give it away (as with G and H).

So:
C=(A*Helium)/B
becomes:
C=(20*2)/8

You can check that this is 5…and so can Leo!

Now, this can be pretty hard to do for complex sentences, for example:

this can be pretty hard to do for complex sentences
ABCD EFG HI JKIAAL BFKM AN MN ONK ENPJQIR DIGAIGEID

A=20
B=8
C=A-(B+Lithium)
D=(C*Lithium)-B
E=(D+Oxygen)/C
F=D-(E*Carbon)
G=(E-F)*Nitrogen
H=(F*G)/Nitrogen
I=(G-Beryllium)/H
J=(I+Lithium)*H
K=(Neon/I)+J
L=(J+K)-Fluorine
M=L-(K+Lithium)
N=(M*Neon)-L
O=(M*N)/Neon
P=N-(O/Lithium)
Q=P-(O/Carbon)
R=24

So, being a lazy sort, I wrote myself a program to do it. (Why work when you can get computers to do it for you?!)

Here’s the program!

It’s not the world’s most sophisticated program. For example, it always uses the last two results as the inputs to the next expression. Sometimes that doesn’t work, given the other constraints that I’ve imposed (for example, the G and H in the first example could probably have been done if I’d allowed it to use other inputs then the previous two). But it works well enough to play.