The puzzle I posted a few days ago is derived from a puzzle that’s worked its way around the Internet every so often in the past few years. See this forum in Russian (why don’t I know Russian?), or Misha Lemeshko’s blog, or Daniel Lemire for the version that mine is derived from. The incarnation I saw on Wednesday, on Facebook, which inspired this post, says that “This problem can be solved by pre-school children in 5-10 minutes, by programmers – in 1 hour, by people with higher education… well, check it yourself! :)

It’s then followed by the following list of numbers:

8809 = 6
7111 = 0
2172 = 0
6666 = 4
1111 = 0
3213 = 0
7662 = 2
9312 = 1
0000 = 4
2222 = 0
3333 = 0
5555 = 0
8193 = 3
8096 = 5
7777 = 0
9999 = 4
7756 = 1
6855 = 3
9881 = 5
5531 = 0

2581 = ?

Sort of implicit in the hint is that maybe it has something to do with the digits; Real Mathematicians think that puzzles involving digits are somehow inferior. (In A Mathematician’s Apology Hardy observes of facts such as 8712 = 4 × 2178 and 153 = 13 + 5 3 + 33 that “[t]hese are odd facts, very suitable for puzzle columns and likely to amuse amateurs, but there is nothing in them which appeals much to a mathematician.”

Perhaps the natural thing to do, if this is a claim about digits, is to then assume that the claim 8809 = 6 encodes the statement $f(8) + f(8) + f(0) + f(9) = 6$, and proceed on that basis. On that basis we have $4f(1) = 0, 4f(0) = 4, 4f(2) = 0, 4f(3) = 0, 4f(5) = 0, 4f(6) = 0, 4f(7) = 0, 4f(9) = 4$ and so $f(0)=f(9) = 1, f(1)=f(2)=f(3)=f(5)=f(6)=f(7)= 0$. We still need $f(4), f(8)$. From the first “equality” we have $2f(8) + f(0) + f(9) = 6$ and so $f(8) = 2$. The answer is $f(2) + f(5) + f(8) + f(1) = 0+0+2+0 = 2$.

As for the version I gave — there are eight equations in nine unknowns. These were derived by removing from the “bloated” version of the puzzle all the equations with four of the same digits on the left side, and all those with a zero on the right side. The system again has equations $f(8) + f(8) + f(0) + f(9) = 6$ and so on. By subtracting equations from each other we get $f(0) = 1 + f(1), f(3) = f(2), f(6) = 1+f(2), f(8) = 2+f(2)$. From “6855 = 3″ we have $f(6) + f(8) + 2f(5) = 3$, or $2f(2) + 2f(5) = 0$; if we agree that all values are nonnegative then $f(2) = f(5) = 0$. Then from “7756 = 1″ we can get $f(7) = 0$. Also from relations we alrady derived, $f(3) = 0, f(6) = 1, f(8) = 2$.

But what are the values of 0, 1, and 9? It turns out that either $(f(0), f(1), f(9)) = (1,0,1)$ or $(2,1,0)$ works, from an addition standpoint.

So why does 4 never appears on the left hand side, therefore meaning we can never work out $f(4)$. This is a feature, not a bug. $f(n)$ is the number of holes in the numeral n. Some people draw 4 with one hole; some draw it with zero. So we choose $(f(0),f(1),f(9)) = (1,0,1)$ and so the answer is $f(2) + f(5) + f(8) + f(1) = 0 + 0 + 2 + 0 = 2$.