# How to tame a Rechenschlange

I found the following problem, called Rechenschlange (literal translation: calculation snake) in a German puzzle calendar:

Fill the blanks with the numbers 1-9. Each number must only appear once. All operators are evaluated left to right.

 xx      xx  :  xx      14
+       +      +       =
10      11     12      13
-       +      -       -
xx      xx     xx      xx
*  xx   :      *  xx   +


(Source: Harenberg Denksport 9. Mai 2014)

In other words:

$(((((((((((a + 10) - b) * c) / d) + 11) + e) / f) + 12) - g) * h) + i - 13 = 14$

or

$\big(\frac{\frac{(a + 10 - b)c}{d} + 11 + e}{f} + 12 - g\big)h + i = 27$

How would I approach this problem mathematically?

My thoughts so far:

• Just (manual) trial and error is not an option, since there are $9! = 362880$ permutations.
• I tried to reduce the search space by going backwards from the result, but, so far, I only managed to deduce that $h \neq 9$. Which means I have only $8! * 8$ permutations left. Great! Then I got stuck.
• The puzzle calendar's puzzles are usually not very hard (crosswords and number pyramids), so I doubt that the intended solution involves high-level number theory. There's a solution at the back of the puzzle sheet, but no explanation on how to get it.
• Maybe there's more than one solution? Maybe there are so many solutions that trial and error is actually the right approach? For fun, I wrote a small script to solve this, which returned 377 unique $(a, ..., i)$ tuples. That's about 1 in 1000, so that can't be the intended solution either.

Unless there's some other unstated constraint, the problem doesn't have a unique solution. Even if you demand an integer at every step of the calculation, you get 301 distinct $(a,\ldots,i)$ tuples that qualify. My guess is that the constructor didn't realize (or care) that there is more than one solution. Writing a small script would be the quickest way to generate all solutions.