I’d like to mathematically solve this calculator game

120 Views Asked by At

The app Calculator: The Game is a puzzle game in which players try to transform a given number into a goal number by using a finite number of operations. Some of these can be very tricky with a trial-and-error method, so I would like to learn how to solve an algorithm of sorts to help.

Here’s an example problem:

Transform $111$ into $126$ in exactly $6$ moves using the following operations:

  • $x\operatorname{A}=x\times3$
  • $x\operatorname{B}=x-9$
  • $x\operatorname{C}=-x$
  • $x\operatorname{D}=\lfloor x/10\rfloor$

where $x$ is the number on the display when the button is pressed)

So, for example, $111\operatorname{A}\operatorname{B}\operatorname{C}\operatorname{D}=-32$.

How could I conceive an equality with iterations of these operations and solve it?

1

There are 1 best solutions below

0
On BEST ANSWER

I don't think there is an easy algorithm, which is what makes it a good puzzle. Some things I would notice to cut down the search space, written as a stream of consciousness: Thinking about rough magnitude, we are starting out about right. Two $A$s and one $D$ leave us about where we started, so we need twice as many $A$s as $D$s. In fact, two $A$s and a $D$ decrease the value, so we can't have four $A$s and two $D$s. They probably created the puzzle to need all the operations, so I would bet on two $A$s and one $D$, but not be shocked if there are none of either. Since we start positive and end positive we need an even number of $C$s. If we don't have any $A$s or $D$s we can only subtract (or add if between $C$s) $9$ and that doesn't get us there, so two $A$s and one $D$ are confirmed. Those will decrease the value, so we need the $+9$ that comes from sandwiching a $B$ between two $C$s. The set of operations is then $AABCCD$ with the $B$ between the $C$s. That doesn't leave much to try.