Enumerate all unique simple arithmetic equations for a set of whole numbers

128 Views Asked by At

When I was younger I used to play a game in my math class: The teacher had a deck of 3x5 cards with a digit written on each one. She would deal out several cards and state a target number, and our goal was to come up with an equation, using only those digits and the operators +,-,*,/ that equaled the stated target.

For example, if the digits were: 3,2,4,6 and the target was 10, you might come up with: (6/2)+3+4 = 10.

I was thinking about this game again recently, and wondered how many unique ways there are to generate a given target to see how "difficult" that target is.

I'm not sure if this is the best way to phrase what I'm asking, but I'm looking for a way to enumerate all the equations you can make with a set of digits and those basic operators (+,-,*,/) that are not redundant. For example, if using the digits 1,2,3, these two equations are redundant by the commutative property: (1+2)+3 and 3+(1+2). In fact all equations using 1,2,3 and the addition operator (only) would be redundant: 1+2+3, 2+1+3, 3+1+2, etc.

Continuing the example from earlier (using the digits 3,2,4,6 and target 10), the equation 3+4+(6/2) is redundant with the one shown earlier, but the alternative equation (6/3)*4+2 = 10 is not. So there are at least 2 ways to make 10 out of those digits. I'm trying to figure out all the non-redundant ways to do so. Is that possible? Is there a better term to describe what I'm looking for?

1

There are 1 best solutions below

2
On BEST ANSWER

The commutation can be captured by the following, moderately complicated, combinatorial object: a rooted tree whose root is labelled $+$ or $\times$, edges are labelled $+$ or $-$, and leaves are labelled with distinct variables. Every branch vertex must have at least two out-edges, and at least one must be labelled $+$.

The interior vertices can be implicitly labelled as the operation which their parent is not.

The value of a leaf is the value of its variable. The value of a $+$ vertex is the sum of its $+$-children minus the sum of its $-$-children. The value of a $\times$ vertex is the product of its $+$-children divided by the product of its $-$-children.

For example, the following tree represents $$\frac{a+b}{c}$$

Tree with two internal nodes and children a,b,c