23
$\begingroup$

How can one get $2015$ using $1,2,\dots,9$ in this order and only once, with the operations $+,-,\times,/$ ?

Solving this riddle with a computer (using python) turned out to be impossible for me due to the amount of memory needed.

Hence, I am looking for a mathematical way to find the/a solution (I am not just looking for the solution, but also for a technique to solve that kind of problems).

$\endgroup$
10
  • 11
    $\begingroup$ You shouldn't need much memory at all. If you nest a bunch of loops over the eight signs, you can evaluate each expression and type it out when the result is 2015. Even if you store them all, $8^4$ is only $4096$ expressions. If you allow parentheses, there are a factor $20793$ more $\endgroup$ Jan 2, 2015 at 0:30
  • 2
    $\begingroup$ @paw88789 Sorry, I should have added that. Parentheses are allowed $\endgroup$ Jan 2, 2015 at 0:36
  • 4
    $\begingroup$ @RossMillikan Thanks, I remade my program (I was using an old version) and found $2015=\left(\left(\left(1+2\right)\cdot 3\cdot 4+5\right)\cdot 6+7\right)\cdot 8-9$ $\endgroup$ Jan 2, 2015 at 0:46
  • 3
    $\begingroup$ @RossMillikan I think you meant $4^8 = 65536$ rather than $8^4$ :). $\endgroup$
    – Erick Wong
    Jan 2, 2015 at 7:03
  • 2
    $\begingroup$ It'd be even more interesting to see all solutions and a proof there isn't more. $\endgroup$
    – chx
    Jan 2, 2015 at 11:26

7 Answers 7

44
$\begingroup$

One technique is to use a product of numbers to get close to the solution and then use the remaining numbers to correct: For example $7\times8\times9=504=\frac{1}{4}\times2016$. Hence we need to generate a factor of $-1$ to add, and a factor of $4$ to multiply. One solution using this idea is

$$-1+(2-3+4-5+6)\times7\times8\times9$$

Another technique is to attempt to use a factorization: $2015=31\times65$ for example. Noting that $-7+8\times9=65$, all we have left to do is generate a factor of $31$. A solution using this idea is $$((1-2)\times(3-4)+5\times6)\times(-7+8\times9)$$

$\endgroup$
2
  • 1
    $\begingroup$ 2015 = 13 * 155. Not 13*65, which equals 845. $\endgroup$
    – Brad
    Jan 2, 2015 at 1:59
  • 1
    $\begingroup$ @Brad oops, yeah I messed up the digits - should have been $31$ instead of $13$. Still, an easy fix. $\endgroup$ Jan 2, 2015 at 2:38
30
$\begingroup$

Peter Woolfitt's answer gives two good approaches to solving this type of problem, but his methods are far from the full story. Using Mathematica, I ran an exhaustive search over all possible parenthesizations of all possible arrangements of $+, -, \times, \div$ among the digits 1 through 9, and came up with 536 distinct* solutions, listed below. There are simply so many ways to combine 9 numbers with 4 operations that no single high-level method can discover them all.

Note that my program distinguishes between different parenthesizations of commutative operations, e.g. ((1 + 2) + 3) and (1 + (2 + 3)) would be considered two distinct solutions. Also, I have only searched for solutions using $-$ as an infix (subtraction) operator, not a unary (negation) operator.

(1 - 2) + ((((3 * (4 + 5)) - 6) + 7) * (8 * 9))
(1 - 2) + ((3 + 4) * ((5 + (6 - 7)) * (8 * 9)))
(1 - 2) + ((3 + 4) * (((5 + 6) - 7) * (8 * 9)))
(1 - 2) + ((((3 * 4) * ((5 + 6) + 7)) + 8) * 9)
(1 - 2) + ((((3 * 4) * (5 + (6 + 7))) + 8) * 9)
(1 - 2) + (((3 * (4 * ((5 + 6) + 7))) + 8) * 9)
(1 - 2) + (((3 * (4 * (5 + (6 + 7)))) + 8) * 9)
(1 - 2) + ((3 + 4) * (((5 + (6 - 7)) * 8) * 9))
(1 - 2) + ((3 + 4) * ((((5 + 6) - 7) * 8) * 9))
(1 - 2) + (((3 * (4 + 5)) - (6 - 7)) * (8 * 9))
(1 - 2) + (((3 + 4) * (5 + (6 - 7))) * (8 * 9))
(1 - 2) + (((3 + 4) * ((5 + 6) - 7)) * (8 * 9))
(1 - 2) + (((((3 * (4 + 5)) - 6) + 7) * 8) * 9)
(1 - 2) + (((3 + 4) * ((5 + (6 - 7)) * 8)) * 9)
(1 - 2) + (((3 + 4) * (((5 + 6) - 7) * 8)) * 9)
(1 - 2) + ((((3 * (4 + 5)) - (6 - 7)) * 8) * 9)
(1 - 2) + ((((3 + 4) * (5 + (6 - 7))) * 8) * 9)
(1 - 2) + ((((3 + 4) * ((5 + 6) - 7)) * 8) * 9)
(((1 - 2) + ((3 * 4) * 5)) * ((6 * 7) - 8)) + 9
(((1 - 2) + (3 * (4 * 5))) * ((6 * 7) - 8)) + 9
((1 - (2 - ((3 * 4) * 5))) * ((6 * 7) - 8)) + 9
((1 - (2 - (3 * (4 * 5)))) * ((6 * 7) - 8)) + 9
((1 * 2) * (3 + ((4 * 5) * ((6 * 7) + 8)))) + 9
((1 * 2) * (3 + (4 * (5 * ((6 * 7) + 8))))) + 9
(1 * (2 * (3 + ((4 * 5) * ((6 * 7) + 8))))) + 9
(1 * (2 * (3 + (4 * (5 * ((6 * 7) + 8)))))) + 9
(1 * 2) + ((3 - (4 * ((5 / 6) - (7 * 8)))) * 9)
((1 * 2) * (3 - ((4 * 5) * (6 - (7 * 8))))) + 9
((1 * 2) * (3 - (4 * (5 * (6 - (7 * 8)))))) + 9
(1 * (2 * (3 - ((4 * 5) * (6 - (7 * 8)))))) + 9
(1 * (2 * (3 - (4 * (5 * (6 - (7 * 8))))))) + 9
(1 * 2) + (3 * (((4 * 5) * ((6 * 7) - 8)) - 9))
(1 * 2) + (3 * ((4 * (5 * ((6 * 7) - 8))) - 9))
1 - (2 + ((3 + (4 - (5 + 6))) * ((7 * 8) * 9)))
1 - (2 + ((3 + (4 - (5 + 6))) * (7 * (8 * 9))))
1 - (2 + ((3 + ((4 - 5) - 6)) * ((7 * 8) * 9)))
1 - (2 + ((3 + ((4 - 5) - 6)) * (7 * (8 * 9))))
1 - (2 + (((3 + 4) - (5 + 6)) * ((7 * 8) * 9)))
1 - (2 + (((3 + 4) - (5 + 6)) * (7 * (8 * 9))))
1 - (2 + (((3 + (4 - 5)) - 6) * ((7 * 8) * 9)))
1 - (2 + (((3 + (4 - 5)) - 6) * (7 * (8 * 9))))
1 - (2 + ((((3 + 4) - 5) - 6) * ((7 * 8) * 9)))
1 - (2 + ((((3 + 4) - 5) - 6) * (7 * (8 * 9))))
1 - (2 + (((3 * (4 - (5 + 6))) - 7) * (8 * 9)))
1 - (2 + (((3 * ((4 - 5) - 6)) - 7) * (8 * 9)))
1 - (2 + (((3 + (4 - (5 + 6))) * (7 * 8)) * 9))
1 - (2 + (((3 + (4 - (5 + 6))) * 7) * (8 * 9)))
1 - (2 + (((3 + ((4 - 5) - 6)) * (7 * 8)) * 9))
1 - (2 + (((3 + ((4 - 5) - 6)) * 7) * (8 * 9)))
1 - (2 + ((((3 + 4) - (5 + 6)) * (7 * 8)) * 9))
1 - (2 + ((((3 + 4) - (5 + 6)) * 7) * (8 * 9)))
1 - (2 + ((((3 + (4 - 5)) - 6) * (7 * 8)) * 9))
1 - (2 + ((((3 + (4 - 5)) - 6) * 7) * (8 * 9)))
1 - ((2 * 3) + (4 * (5 - (6 + ((7 * 8) * 9)))))
1 - ((2 * 3) + (4 * (5 - (6 + (7 * (8 * 9))))))
1 - (2 + (((((3 + 4) - 5) - 6) * (7 * 8)) * 9))
1 - (2 + (((((3 + 4) - 5) - 6) * 7) * (8 * 9)))
1 - ((2 * 3) + (4 * ((5 - 6) - ((7 * 8) * 9))))
1 - ((2 * 3) + (4 * ((5 - 6) - (7 * (8 * 9)))))
1 - (2 + ((((3 * (4 - (5 + 6))) - 7) * 8) * 9))
1 - (2 + ((((3 * ((4 - 5) - 6)) - 7) * 8) * 9))
1 - (2 + ((((3 + (4 - (5 + 6))) * 7) * 8) * 9))
1 - (2 + ((((3 + ((4 - 5) - 6)) * 7) * 8) * 9))
1 - (2 + (((((3 + 4) - (5 + 6)) * 7) * 8) * 9))
1 - (2 + (((((3 + (4 - 5)) - 6) * 7) * 8) * 9))
1 - (2 + ((((((3 + 4) - 5) - 6) * 7) * 8) * 9))
(1 - 2) - ((3 + (4 - (5 + 6))) * ((7 * 8) * 9))
(1 - 2) - ((3 + (4 - (5 + 6))) * (7 * (8 * 9)))
(1 - 2) - ((3 + ((4 - 5) - 6)) * ((7 * 8) * 9))
(1 - 2) - ((3 + ((4 - 5) - 6)) * (7 * (8 * 9)))
1 - (2 - ((((3 * (4 + 5)) - 6) + 7) * (8 * 9)))
1 - (2 - ((3 + 4) * ((5 + (6 - 7)) * (8 * 9))))
1 - (2 - ((3 + 4) * (((5 + 6) - 7) * (8 * 9))))
1 - (2 - ((((3 * 4) * ((5 + 6) + 7)) + 8) * 9))
1 - (2 - ((((3 * 4) * (5 + (6 + 7))) + 8) * 9))
1 - (2 - (((3 * (4 * ((5 + 6) + 7))) + 8) * 9))
1 - (2 - (((3 * (4 * (5 + (6 + 7)))) + 8) * 9))
1 - (2 - ((3 + 4) * (((5 + (6 - 7)) * 8) * 9)))
1 - (2 - ((3 + 4) * ((((5 + 6) - 7) * 8) * 9)))
(1 - 2) - (((3 + 4) - (5 + 6)) * ((7 * 8) * 9))
(1 - 2) - (((3 + 4) - (5 + 6)) * (7 * (8 * 9)))
(1 - 2) - (((3 + (4 - 5)) - 6) * ((7 * 8) * 9))
(1 - 2) - (((3 + (4 - 5)) - 6) * (7 * (8 * 9)))
(1 - 2) - ((((3 + 4) - 5) - 6) * ((7 * 8) * 9))
(1 - 2) - ((((3 + 4) - 5) - 6) * (7 * (8 * 9)))
1 - (2 - (((3 * (4 + 5)) - (6 - 7)) * (8 * 9)))
(1 - 2) - (((3 * (4 - (5 + 6))) - 7) * (8 * 9))
(1 - 2) - (((3 * ((4 - 5) - 6)) - 7) * (8 * 9))
1 - (2 - (((3 + 4) * (5 + (6 - 7))) * (8 * 9)))
(1 - 2) - (((3 + (4 - (5 + 6))) * (7 * 8)) * 9)
(1 - 2) - (((3 + (4 - (5 + 6))) * 7) * (8 * 9))
1 - (2 - (((3 + 4) * ((5 + 6) - 7)) * (8 * 9)))
(1 - 2) - (((3 + ((4 - 5) - 6)) * (7 * 8)) * 9)
(1 - 2) - (((3 + ((4 - 5) - 6)) * 7) * (8 * 9))
1 - (2 - (((((3 * (4 + 5)) - 6) + 7) * 8) * 9))
1 - (2 - (((3 + 4) * ((5 + (6 - 7)) * 8)) * 9))
1 - (2 - (((3 + 4) * (((5 + 6) - 7) * 8)) * 9))
(1 - 2) - ((((3 + 4) - (5 + 6)) * (7 * 8)) * 9)
(1 - 2) - ((((3 + 4) - (5 + 6)) * 7) * (8 * 9))
(1 - 2) - ((((3 + (4 - 5)) - 6) * (7 * 8)) * 9)
(1 - 2) - ((((3 + (4 - 5)) - 6) * 7) * (8 * 9))
(1 - (2 * 3)) - (4 * (5 - (6 + ((7 * 8) * 9))))
(1 - (2 * 3)) - (4 * (5 - (6 + (7 * (8 * 9)))))
(1 - 2) - (((((3 + 4) - 5) - 6) * (7 * 8)) * 9)
(1 - 2) - (((((3 + 4) - 5) - 6) * 7) * (8 * 9))
(1 - (2 * 3)) - (4 * ((5 - 6) - ((7 * 8) * 9)))
(1 - (2 * 3)) - (4 * ((5 - 6) - (7 * (8 * 9))))
1 - (2 - ((((3 * (4 + 5)) - (6 - 7)) * 8) * 9))
(1 - 2) - ((((3 * (4 - (5 + 6))) - 7) * 8) * 9)
(1 - 2) - ((((3 * ((4 - 5) - 6)) - 7) * 8) * 9)
1 - (2 - ((((3 + 4) * (5 + (6 - 7))) * 8) * 9))
(1 - 2) - ((((3 + (4 - (5 + 6))) * 7) * 8) * 9)
1 - (2 - ((((3 + 4) * ((5 + 6) - 7)) * 8) * 9))
(1 - 2) - ((((3 + ((4 - 5) - 6)) * 7) * 8) * 9)
(1 - 2) - (((((3 + 4) - (5 + 6)) * 7) * 8) * 9)
(1 - 2) - (((((3 + (4 - 5)) - 6) * 7) * 8) * 9)
(1 - 2) - ((((((3 + 4) - 5) - 6) * 7) * 8) * 9)
((1 * 2) - 3) - ((4 * (5 - 6)) * ((7 * 8) * 9))
((1 * 2) - 3) - ((4 * (5 - 6)) * (7 * (8 * 9)))
((1 * 2) - 3) - (4 * ((5 - 6) * ((7 * 8) * 9)))
((1 * 2) - 3) - (4 * ((5 - 6) * (7 * (8 * 9))))
((1 * 2) - 3) - (((4 * (5 - 6)) * (7 * 8)) * 9)
((1 * 2) - 3) - ((4 * ((5 - 6) * (7 * 8))) * 9)
((1 * 2) - 3) - (((4 * (5 - 6)) * 7) * (8 * 9))
((1 * 2) - 3) - ((4 * ((5 - 6) * 7)) * (8 * 9))
((1 * 2) - 3) - (4 * (((5 - 6) * (7 * 8)) * 9))
((1 * 2) - 3) - (4 * (((5 - 6) * 7) * (8 * 9)))
((1 * 2) - 3) - ((((4 * (5 - 6)) * 7) * 8) * 9)
((1 * 2) - 3) - (((4 * ((5 - 6) * 7)) * 8) * 9)
((1 * 2) - 3) - ((4 * (((5 - 6) * 7) * 8)) * 9)
((1 * 2) - 3) - (4 * ((((5 - 6) * 7) * 8) * 9))
((1 * 2) - 3) - ((((4 / (5 - 6)) * 7) * 8) * 9)
((1 * 2) - 3) - (((4 / (5 - 6)) * (7 * 8)) * 9)
((1 * 2) - 3) - (((4 / (5 - 6)) * 7) * (8 * 9))
((1 * 2) - 3) - (((4 / ((5 - 6) / 7)) * 8) * 9)
((1 * 2) - 3) - ((4 / (5 - 6)) * ((7 * 8) * 9))
((1 * 2) - 3) - ((4 / (5 - 6)) * (7 * (8 * 9)))
((1 * 2) - 3) - ((4 / ((5 - 6) / (7 * 8))) * 9)
((1 * 2) - 3) - ((4 / ((5 - 6) / 7)) * (8 * 9))
((1 * 2) - 3) - ((4 / (((5 - 6) / 7) / 8)) * 9)
((1 * 2) - 3) - (4 / ((5 - 6) / ((7 * 8) * 9)))
((1 * 2) - 3) - (4 / ((5 - 6) / (7 * (8 * 9))))
((1 * 2) - 3) - (4 / (((5 - 6) / (7 * 8)) / 9))
((1 * 2) - 3) - (4 / (((5 - 6) / 7) / (8 * 9)))
((1 * 2) - 3) - (4 / ((((5 - 6) / 7) / 8) / 9))
(((1 + (2 * 3)) + 4) * (((5 * 6) - 7) * 8)) - 9
((1 + ((2 * 3) + 4)) * (((5 * 6) - 7) * 8)) - 9
(((1 - 2) + (3 * 4)) * (((5 * 6) - 7) * 8)) - 9
((1 + (((2 + (3 - 4)) + 5) * (6 * 7))) * 8) - 9
((1 + ((2 + ((3 - 4) + 5)) * (6 * 7))) * 8) - 9
((1 + ((((2 + 3) - 4) + 5) * (6 * 7))) * 8) - 9
((1 + ((2 + (3 - (4 - 5))) * (6 * 7))) * 8) - 9
((1 + ((2 + (3 * 4)) * ((5 + 6) + 7))) * 8) - 9
((1 + ((2 + (3 * 4)) * (5 + (6 + 7)))) * 8) - 9
((((((1 + 2) * (3 * 4)) + 5) * 6) + 7) * 8) - 9
(((((((1 + 2) * 3) * 4) + 5) * 6) + 7) * 8) - 9
((1 + (((2 + 3) - (4 - 5)) * (6 * 7))) * 8) - 9
((1 + ((2 * (((3 + 4) + 5) + 6)) * 7)) * 8) - 9
((1 + ((2 * ((3 + (4 + 5)) + 6)) * 7)) * 8) - 9
((1 + ((2 * ((3 + 4) + (5 + 6))) * 7)) * 8) - 9
((1 + ((2 * (3 + ((4 + 5) + 6))) * 7)) * 8) - 9
((1 + ((2 * (3 + (4 + (5 + 6)))) * 7)) * 8) - 9
((1 + ((2 * (3 + 4)) * ((5 + 6) + 7))) * 8) - 9
((1 + ((2 * (3 + 4)) * (5 + (6 + 7)))) * 8) - 9
((1 + (2 * ((((3 + 4) + 5) + 6) * 7))) * 8) - 9
((1 + (2 * (((3 + (4 + 5)) + 6) * 7))) * 8) - 9
((1 + (2 * (((3 + 4) + (5 + 6)) * 7))) * 8) - 9
((1 + (2 * ((3 + ((4 + 5) + 6)) * 7))) * 8) - 9
((1 + (2 * ((3 + (4 + (5 + 6))) * 7))) * 8) - 9
((1 + (2 * ((3 + 4) * ((5 + 6) + 7)))) * 8) - 9
((1 + (2 * ((3 + 4) * (5 + (6 + 7))))) * 8) - 9
((1 + ((((2 + (3 - 4)) + 5) * 6) * 7)) * 8) - 9
((1 + (((2 + ((3 - 4) + 5)) * 6) * 7)) * 8) - 9
((1 + (((((2 + 3) - 4) + 5) * 6) * 7)) * 8) - 9
((1 + (((2 + (3 - (4 - 5))) * 6) * 7)) * 8) - 9
((((1 * 2) * (3 + ((4 * 5) * 6))) + 7) * 8) - 9
((((1 * 2) * (3 + (4 * (5 * 6)))) + 7) * 8) - 9
(((1 * (2 * (3 + ((4 * 5) * 6)))) + 7) * 8) - 9
(((1 * (2 * (3 + (4 * (5 * 6))))) + 7) * 8) - 9
((1 + ((((2 + 3) - (4 - 5)) * 6) * 7)) * 8) - 9
(1 * 2) - (3 + ((4 * (5 - 6)) * ((7 * 8) * 9)))
(1 * 2) - (3 + ((4 * (5 - 6)) * (7 * (8 * 9))))
(1 * 2) - (3 + (4 * ((5 - 6) * ((7 * 8) * 9))))
(1 * 2) - (3 + (4 * ((5 - 6) * (7 * (8 * 9)))))
(1 * 2) - (3 + (((4 * (5 - 6)) * (7 * 8)) * 9))
(1 * 2) - (3 + ((4 * ((5 - 6) * (7 * 8))) * 9))
(1 * 2) - (3 + (((4 * (5 - 6)) * 7) * (8 * 9)))
(1 * 2) - (3 + ((4 * ((5 - 6) * 7)) * (8 * 9)))
(1 * 2) - (3 + (4 * (((5 - 6) * (7 * 8)) * 9)))
(1 * 2) - (3 + (4 * (((5 - 6) * 7) * (8 * 9))))
(1 * 2) - (3 + ((((4 * (5 - 6)) * 7) * 8) * 9))
(1 * 2) - (3 + (((4 * ((5 - 6) * 7)) * 8) * 9))
(1 * 2) - (3 + ((4 * (((5 - 6) * 7) * 8)) * 9))
(1 * 2) - (3 + (4 * ((((5 - 6) * 7) * 8) * 9)))
((1 + ((((2 / 3) * (4 + 5)) * 6) * 7)) * 8) - 9
(1 * 2) - (3 + ((((4 / (5 - 6)) * 7) * 8) * 9))
((1 + (((2 / 3) * (4 + 5)) * (6 * 7))) * 8) - 9
(1 * 2) - (3 + (((4 / (5 - 6)) * (7 * 8)) * 9))
(1 * 2) - (3 + (((4 / (5 - 6)) * 7) * (8 * 9)))
((1 + (((2 / 3) * ((4 + 5) * 6)) * 7)) * 8) - 9
((1 + (((2 / (3 / (4 + 5))) * 6) * 7)) * 8) - 9
(1 * 2) - (3 + (((4 / ((5 - 6) / 7)) * 8) * 9))
(1 * 2) - (3 + ((4 / (5 - 6)) * ((7 * 8) * 9)))
(1 * 2) - (3 + ((4 / (5 - 6)) * (7 * (8 * 9))))
((1 + ((2 / 3) * ((4 + 5) * (6 * 7)))) * 8) - 9
((1 + ((2 / 3) * (((4 + 5) * 6) * 7))) * 8) - 9
((1 + ((2 / (3 / (4 + 5))) * (6 * 7))) * 8) - 9
(1 * 2) - (3 + ((4 / ((5 - 6) / (7 * 8))) * 9))
(1 * 2) - (3 + ((4 / ((5 - 6) / 7)) * (8 * 9)))
((1 + ((2 / (3 / ((4 + 5) * 6))) * 7)) * 8) - 9
((1 + ((2 / ((3 / (4 + 5)) / 6)) * 7)) * 8) - 9
(1 * 2) - (3 + ((4 / (((5 - 6) / 7) / 8)) * 9))
(1 * 2) - (3 + (4 / ((5 - 6) / ((7 * 8) * 9))))
(1 * 2) - (3 + (4 / ((5 - 6) / (7 * (8 * 9)))))
((1 + (2 / (3 / ((4 + 5) * (6 * 7))))) * 8) - 9
((1 + (2 / (3 / (((4 + 5) * 6) * 7)))) * 8) - 9
((1 + (2 / ((3 / (4 + 5)) / (6 * 7)))) * 8) - 9
(1 * 2) - (3 + (4 / (((5 - 6) / (7 * 8)) / 9)))
(1 * 2) - (3 + (4 / (((5 - 6) / 7) / (8 * 9))))
((1 + (2 / ((3 / ((4 + 5) * 6)) / 7))) * 8) - 9
((1 + (2 / (((3 / (4 + 5)) / 6) / 7))) * 8) - 9
(1 * 2) - (3 + (4 / ((((5 - 6) / 7) / 8) / 9)))
((1 - (2 - (3 * 4))) * (((5 * 6) - 7) * 8)) - 9
((1 - ((2 * ((3 * 4) - (5 * 6))) * 7)) * 8) - 9
((1 - (2 * (((3 * 4) - (5 * 6)) * 7))) * 8) - 9
(1 * (2 - 3)) - ((4 * (5 - 6)) * ((7 * 8) * 9))
(1 * (2 - 3)) - ((4 * (5 - 6)) * (7 * (8 * 9)))
(1 * (2 - 3)) - (4 * ((5 - 6) * ((7 * 8) * 9)))
(1 * (2 - 3)) - (4 * ((5 - 6) * (7 * (8 * 9))))
((1 - (((2 * 3) * (4 - 5)) * (6 * 7))) * 8) - 9
((1 - ((2 * (3 * (4 - 5))) * (6 * 7))) * 8) - 9
((1 - ((2 * 3) * ((4 - 5) * (6 * 7)))) * 8) - 9
((1 - (2 * ((3 * (4 - 5)) * (6 * 7)))) * 8) - 9
((1 - (2 * (3 * ((4 - 5) * (6 * 7))))) * 8) - 9
(1 * (2 - 3)) - (((4 * (5 - 6)) * (7 * 8)) * 9)
(1 * (2 - 3)) - ((4 * ((5 - 6) * (7 * 8))) * 9)
(1 * (2 - 3)) - (((4 * (5 - 6)) * 7) * (8 * 9))
(1 * (2 - 3)) - ((4 * ((5 - 6) * 7)) * (8 * 9))
(1 * (2 - 3)) - (4 * (((5 - 6) * (7 * 8)) * 9))
(1 * (2 - 3)) - (4 * (((5 - 6) * 7) * (8 * 9)))
((1 - ((((2 * 3) * (4 - 5)) * 6) * 7)) * 8) - 9
((1 - (((2 * (3 * (4 - 5))) * 6) * 7)) * 8) - 9
((1 - (((2 * 3) * ((4 - 5) * 6)) * 7)) * 8) - 9
((1 - ((2 * ((3 * (4 - 5)) * 6)) * 7)) * 8) - 9
((1 - ((2 * (3 * ((4 - 5) * 6))) * 7)) * 8) - 9
((1 - ((2 * 3) * (((4 - 5) * 6) * 7))) * 8) - 9
((1 - (2 * (((3 * (4 - 5)) * 6) * 7))) * 8) - 9
((1 - (2 * ((3 * ((4 - 5) * 6)) * 7))) * 8) - 9
((1 - (2 * (3 * (((4 - 5) * 6) * 7)))) * 8) - 9
(1 * (2 - 3)) - ((((4 * (5 - 6)) * 7) * 8) * 9)
(1 * (2 - 3)) - (((4 * ((5 - 6) * 7)) * 8) * 9)
(1 * (2 - 3)) - ((4 * (((5 - 6) * 7) * 8)) * 9)
(1 * (2 - 3)) - (4 * ((((5 - 6) * 7) * 8) * 9))
((1 - (((2 * (3 / (4 - 5))) * 6) * 7)) * 8) - 9
((1 - ((2 * ((3 / (4 - 5)) * 6)) * 7)) * 8) - 9
((1 - (2 * (((3 / (4 - 5)) * 6) * 7))) * 8) - 9
(1 * (2 - 3)) - ((((4 / (5 - 6)) * 7) * 8) * 9)
((1 - ((2 * (3 / (4 - 5))) * (6 * 7))) * 8) - 9
((1 - (2 * ((3 / (4 - 5)) * (6 * 7)))) * 8) - 9
(1 * (2 - 3)) - (((4 / (5 - 6)) * (7 * 8)) * 9)
(1 * (2 - 3)) - (((4 / (5 - 6)) * 7) * (8 * 9))
((1 - ((((2 * 3) / (4 - 5)) * 6) * 7)) * 8) - 9
((1 - ((2 * (3 / ((4 - 5) / 6))) * 7)) * 8) - 9
((1 - (2 * ((3 / ((4 - 5) / 6)) * 7))) * 8) - 9
(1 * (2 - 3)) - (((4 / ((5 - 6) / 7)) * 8) * 9)
(1 * (2 - 3)) - ((4 / (5 - 6)) * ((7 * 8) * 9))
(1 * (2 - 3)) - ((4 / (5 - 6)) * (7 * (8 * 9)))
((1 - (((2 * 3) / (4 - 5)) * (6 * 7))) * 8) - 9
((1 - (((2 * 3) / ((4 - 5) / 6)) * 7)) * 8) - 9
((1 - (2 * (3 / ((4 - 5) / (6 * 7))))) * 8) - 9
(1 * (2 - 3)) - ((4 / ((5 - 6) / (7 * 8))) * 9)
(1 * (2 - 3)) - ((4 / ((5 - 6) / 7)) * (8 * 9))
((1 - (2 * (3 / (((4 - 5) / 6) / 7)))) * 8) - 9
(1 * (2 - 3)) - ((4 / (((5 - 6) / 7) / 8)) * 9)
((1 - ((2 * 3) / ((4 - 5) / (6 * 7)))) * 8) - 9
((1 - ((2 * 3) / (((4 - 5) / 6) / 7))) * 8) - 9
(1 * (2 - 3)) - (4 / ((5 - 6) / ((7 * 8) * 9)))
(1 * (2 - 3)) - (4 / ((5 - 6) / (7 * (8 * 9))))
(1 * (2 - 3)) - (4 / (((5 - 6) / (7 * 8)) / 9))
(1 * (2 - 3)) - (4 / (((5 - 6) / 7) / (8 * 9)))
(1 * (2 - 3)) - (4 / ((((5 - 6) / 7) / 8) / 9))
((((1 + (2 * 3)) + 4) * ((5 * 6) - 7)) * 8) - 9
(((1 + ((2 * 3) + 4)) * ((5 * 6) - 7)) * 8) - 9
((((1 - 2) + (3 * 4)) * ((5 * 6) - 7)) * 8) - 9
((1 * ((2 * (3 + ((4 * 5) * 6))) + 7)) * 8) - 9
((1 * ((2 * (3 + (4 * (5 * 6)))) + 7)) * 8) - 9
(1 * (((2 * (3 + ((4 * 5) * 6))) + 7) * 8)) - 9
(1 * (((2 * (3 + (4 * (5 * 6)))) + 7) * 8)) - 9
(((1 - (2 - (3 * 4))) * ((5 * 6) - 7)) * 8) - 9
(1 / (2 - 3)) - ((4 * (5 - 6)) * ((7 * 8) * 9))
(1 / (2 - 3)) - ((4 * (5 - 6)) * (7 * (8 * 9)))
(1 / (2 - 3)) - (4 * ((5 - 6) * ((7 * 8) * 9)))
(1 / (2 - 3)) - (4 * ((5 - 6) * (7 * (8 * 9))))
(1 / (2 - 3)) - (((4 * (5 - 6)) * (7 * 8)) * 9)
(1 / (2 - 3)) - ((4 * ((5 - 6) * (7 * 8))) * 9)
(1 / (2 - 3)) - (((4 * (5 - 6)) * 7) * (8 * 9))
(1 / (2 - 3)) - ((4 * ((5 - 6) * 7)) * (8 * 9))
(1 / (2 - 3)) - (4 * (((5 - 6) * (7 * 8)) * 9))
(1 / (2 - 3)) - (4 * (((5 - 6) * 7) * (8 * 9)))
(1 / (2 - 3)) - ((((4 * (5 - 6)) * 7) * 8) * 9)
(1 / (2 - 3)) - (((4 * ((5 - 6) * 7)) * 8) * 9)
(1 / (2 - 3)) - ((4 * (((5 - 6) * 7) * 8)) * 9)
(1 / (2 - 3)) - (4 * ((((5 - 6) * 7) * 8) * 9))
(1 / (2 - 3)) - ((((4 / (5 - 6)) * 7) * 8) * 9)
(1 / (2 - 3)) - (((4 / (5 - 6)) * (7 * 8)) * 9)
(1 / (2 - 3)) - (((4 / (5 - 6)) * 7) * (8 * 9))
(1 / (2 - 3)) - (((4 / ((5 - 6) / 7)) * 8) * 9)
(1 / (2 - 3)) - ((4 / (5 - 6)) * ((7 * 8) * 9))
(1 / (2 - 3)) - ((4 / (5 - 6)) * (7 * (8 * 9)))
(1 / (2 - 3)) - ((4 / ((5 - 6) / (7 * 8))) * 9)
(1 / (2 - 3)) - ((4 / ((5 - 6) / 7)) * (8 * 9))
(1 / (2 - 3)) - ((4 / (((5 - 6) / 7) / 8)) * 9)
(1 / (2 - 3)) - (4 / ((5 - 6) / ((7 * 8) * 9)))
(1 / (2 - 3)) - (4 / ((5 - 6) / (7 * (8 * 9))))
(1 / (2 - 3)) - (4 / (((5 - 6) / (7 * 8)) / 9))
(1 / (2 - 3)) - (4 / (((5 - 6) / 7) / (8 * 9)))
(1 / (2 - 3)) - (4 / ((((5 - 6) / 7) / 8) / 9))
(1 / 2) - (((3 / 4) - 5) * (6 * (7 + (8 * 9))))
(1 / 2) - ((((3 / 4) - 5) * 6) * (7 + (8 * 9)))
((((1 * 2) + 3) + (4 * 5)) + 6) * ((7 * 8) + 9)
((1 + (2 * ((3 + 4) + 5))) + 6) * ((7 * 8) + 9)
((1 + (2 * (3 + (4 + 5)))) + 6) * ((7 * 8) + 9)
(1 + ((2 * ((3 + 4) + 5)) + 6)) * ((7 * 8) + 9)
(1 + ((2 * (3 + (4 + 5))) + 6)) * ((7 * 8) + 9)
(((((1 * 2) + 3) * 4) + 5) + 6) * ((7 * 8) + 9)
(((1 * (2 + 3)) + (4 * 5)) + 6) * ((7 * 8) + 9)
(((1 * 2) + (3 + (4 * 5))) + 6) * ((7 * 8) + 9)
(((1 * 2) + 3) + ((4 * 5) + 6)) * ((7 * 8) + 9)
((((1 - 2) * 3) + 4) + (5 * 6)) * ((7 * 8) + 9)
(((1 * 2) + (3 - 4)) + (5 * 6)) * ((7 * 8) + 9)
((((1 * (2 + 3)) * 4) + 5) + 6) * ((7 * 8) + 9)
(((1 * ((2 + 3) * 4)) + 5) + 6) * ((7 * 8) + 9)
((((1 * 2) + 3) - 4) + (5 * 6)) * ((7 * 8) + 9)
(((1 * (2 + 3)) - 4) + (5 * 6)) * ((7 * 8) + 9)
((1 - (2 * 3)) + (4 - (5 * 6))) * (7 - (8 * 9))
((1 - 2) + ((3 - 4) * (5 * 6))) * (7 - (8 * 9))
(1 + ((2 * (3 - 4)) - (5 * 6))) * (7 - (8 * 9))
((1 - 2) + (((3 - 4) * 5) * 6)) * (7 - (8 * 9))
(1 + ((2 / (3 - 4)) - (5 * 6))) * (7 - (8 * 9))
((1 * ((2 + 3) + (4 * 5))) + 6) * ((7 * 8) + 9)
((1 * (2 + (3 + (4 * 5)))) + 6) * ((7 * 8) + 9)
((1 * (2 + 3)) + ((4 * 5) + 6)) * ((7 * 8) + 9)
((1 * 2) + ((3 + (4 * 5)) + 6)) * ((7 * 8) + 9)
((1 * 2) + (3 + ((4 * 5) + 6))) * ((7 * 8) + 9)
((1 * (2 + (3 - 4))) + (5 * 6)) * ((7 * 8) + 9)
((1 * 2) + ((3 - 4) + (5 * 6))) * ((7 * 8) + 9)
(1 + ((2 + (3 - 4)) * (5 * 6))) * ((7 * 8) + 9)
((1 * (((2 + 3) * 4) + 5)) + 6) * ((7 * 8) + 9)
((((1 * 2) + 3) * 4) + (5 + 6)) * ((7 * 8) + 9)
(1 + (((2 * 3) + (4 - 5)) * 6)) * ((7 * 8) + 9)
1 * ((2 * (3 + ((4 * 5) * ((6 * 7) + 8)))) + 9)
1 * ((2 * (3 + (4 * (5 * ((6 * 7) + 8))))) + 9)
(((((1 + 2) / 3) + 4) * 5) + 6) * ((7 * 8) + 9)
((1 * ((2 + 3) - 4)) + (5 * 6)) * ((7 * 8) + 9)
(((1 - 2) * 3) + (4 + (5 * 6))) * ((7 * 8) + 9)
(1 + ((((2 * 3) + 4) - 5) * 6)) * ((7 * 8) + 9)
(1 + (((2 + 3) - 4) * (5 * 6))) * ((7 * 8) + 9)
(((1 - 2) * (3 - 4)) + (5 * 6)) * ((7 * 8) + 9)
((1 * 2) + (3 - (4 - (5 * 6)))) * ((7 * 8) + 9)
(((((1 + 2) * 3) - 4) * 5) + 6) * ((7 * 8) + 9)
((1 * 2) + (((3 + 4) * 5) - 6)) * ((7 * 8) + 9)
(((1 - ((2 - 3) * 4)) * 5) + 6) * ((7 * 8) + 9)
(1 + ((2 - (3 * (4 - 5))) * 6)) * ((7 * 8) + 9)
1 * (2 + ((3 - (4 * ((5 / 6) - (7 * 8)))) * 9))
1 * ((2 * (3 - ((4 * 5) * (6 - (7 * 8))))) + 9)
1 * ((2 * (3 - (4 * (5 * (6 - (7 * 8)))))) + 9)
1 * (2 + (3 * (((4 * 5) * ((6 * 7) - 8)) - 9)))
1 * (2 + (3 * ((4 * (5 * ((6 * 7) - 8))) - 9)))
(1 + ((2 - (3 / (4 - 5))) * 6)) * ((7 * 8) + 9)
(((1 * (2 + 3)) * 4) + (5 + 6)) * ((7 * 8) + 9)
((1 * ((2 + 3) * 4)) + (5 + 6)) * ((7 * 8) + 9)
(1 + (((2 + (3 - 4)) * 5) * 6)) * ((7 * 8) + 9)
(1 + ((2 * 3) * ((4 - 5) + 6))) * ((7 * 8) + 9)
(1 + (2 * (3 * ((4 - 5) + 6)))) * ((7 * 8) + 9)
(1 + ((((2 + 3) - 4) * 5) * 6)) * ((7 * 8) + 9)
(1 + ((2 * 3) * (4 - (5 - 6)))) * ((7 * 8) + 9)
(1 + (2 * (3 * (4 - (5 - 6))))) * ((7 * 8) + 9)
((1 * (2 / (3 * 4))) + 5) * (6 * ((7 * 8) + 9))
((1 * ((2 / 3) / 4)) + 5) * (6 * ((7 * 8) + 9))
((1 / (2 + (3 - 4))) + (5 * 6)) * ((7 * 8) + 9)
((1 / ((2 + 3) - 4)) + (5 * 6)) * ((7 * 8) + 9)
(((1 - 2) / (3 - 4)) + (5 * 6)) * ((7 * 8) + 9)
(((1 * 2) / (3 * 4)) + 5) * (6 * ((7 * 8) + 9))
(((1 * (2 / 3)) / 4) + 5) * (6 * ((7 * 8) + 9))
((((1 * 2) / 3) / 4) + 5) * (6 * ((7 * 8) + 9))
(1 - (((2 * 3) + (4 * 5)) + 6)) * (7 - (8 * 9))
(((1 - (2 * 3)) + 4) - (5 * 6)) * (7 - (8 * 9))
(1 - (((2 * 3) - 4) + (5 * 6))) * (7 - (8 * 9))
(1 - ((2 * 3) + ((4 * 5) + 6))) * (7 - (8 * 9))
(((1 * 2) + 3) - (4 - (5 * 6))) * ((7 * 8) + 9)
((1 + (2 * (3 - 4))) - (5 * 6)) * (7 - (8 * 9))
(((1 * 2) + ((3 + 4) * 5)) - 6) * ((7 * 8) + 9)
1 * (2 - (3 + ((4 * (5 - 6)) * ((7 * 8) * 9))))
1 * (2 - (3 + ((4 * (5 - 6)) * (7 * (8 * 9)))))
1 * (2 - (3 + (4 * ((5 - 6) * ((7 * 8) * 9)))))
1 * (2 - (3 + (4 * ((5 - 6) * (7 * (8 * 9))))))
1 * (2 - (3 + (((4 * (5 - 6)) * (7 * 8)) * 9)))
1 * (2 - (3 + ((4 * ((5 - 6) * (7 * 8))) * 9)))
1 * (2 - (3 + (((4 * (5 - 6)) * 7) * (8 * 9))))
1 * (2 - (3 + ((4 * ((5 - 6) * 7)) * (8 * 9))))
1 * (2 - (3 + (4 * (((5 - 6) * (7 * 8)) * 9))))
1 * (2 - (3 + (4 * (((5 - 6) * 7) * (8 * 9)))))
1 * (2 - (3 + ((((4 * (5 - 6)) * 7) * 8) * 9)))
1 * (2 - (3 + (((4 * ((5 - 6) * 7)) * 8) * 9)))
1 * (2 - (3 + ((4 * (((5 - 6) * 7) * 8)) * 9)))
1 * (2 - (3 + (4 * ((((5 - 6) * 7) * 8) * 9))))
1 * (2 - (3 + ((((4 / (5 - 6)) * 7) * 8) * 9)))
1 * (2 - (3 + (((4 / (5 - 6)) * (7 * 8)) * 9)))
1 * (2 - (3 + (((4 / (5 - 6)) * 7) * (8 * 9))))
1 * (2 - (3 + (((4 / ((5 - 6) / 7)) * 8) * 9)))
1 * (2 - (3 + ((4 / (5 - 6)) * ((7 * 8) * 9))))
1 * (2 - (3 + ((4 / (5 - 6)) * (7 * (8 * 9)))))
1 * (2 - (3 + ((4 / ((5 - 6) / (7 * 8))) * 9)))
1 * (2 - (3 + ((4 / ((5 - 6) / 7)) * (8 * 9))))
1 * (2 - (3 + ((4 / (((5 - 6) / 7) / 8)) * 9)))
((1 + (2 / (3 - 4))) - (5 * 6)) * (7 - (8 * 9))
1 * (2 - (3 + (4 / ((5 - 6) / ((7 * 8) * 9)))))
1 * (2 - (3 + (4 / ((5 - 6) / (7 * (8 * 9))))))
1 * (2 - (3 + (4 / (((5 - 6) / (7 * 8)) / 9))))
1 * (2 - (3 + (4 / (((5 - 6) / 7) / (8 * 9)))))
1 * (2 - (3 + (4 / ((((5 - 6) / 7) / 8) / 9))))
((1 - ((2 * 3) + (4 * 5))) - 6) * (7 - (8 * 9))
(((1 - (2 * 3)) - (4 * 5)) - 6) * (7 - (8 * 9))
((1 - ((2 * 3) - 4)) - (5 * 6)) * (7 - (8 * 9))
((1 - (2 * 3)) - ((4 * 5) + 6)) * (7 - (8 * 9))
((((1 - (2 * 3)) * 4) - 5) - 6) * (7 - (8 * 9))
(1 - ((2 * 3) - (4 - (5 * 6)))) * (7 - (8 * 9))
(1 - (2 - ((3 - 4) * (5 * 6)))) * (7 - (8 * 9))
(((1 * 2) - (3 * (4 + 5))) - 6) * (7 - (8 * 9))
(1 - (2 - (((3 - 4) * 5) * 6))) * (7 - (8 * 9))
1 * ((2 - 3) - ((4 * (5 - 6)) * ((7 * 8) * 9)))
1 * ((2 - 3) - ((4 * (5 - 6)) * (7 * (8 * 9))))
1 * ((2 - 3) - (4 * ((5 - 6) * ((7 * 8) * 9))))
1 * ((2 - 3) - (4 * ((5 - 6) * (7 * (8 * 9)))))
1 * ((2 - 3) - (((4 * (5 - 6)) * (7 * 8)) * 9))
1 * ((2 - 3) - ((4 * ((5 - 6) * (7 * 8))) * 9))
1 * ((2 - 3) - (((4 * (5 - 6)) * 7) * (8 * 9)))
1 * ((2 - 3) - ((4 * ((5 - 6) * 7)) * (8 * 9)))
1 * ((2 - 3) - (4 * (((5 - 6) * (7 * 8)) * 9)))
1 * ((2 - 3) - (4 * (((5 - 6) * 7) * (8 * 9))))
1 * ((2 - 3) - ((((4 * (5 - 6)) * 7) * 8) * 9))
1 * ((2 - 3) - (((4 * ((5 - 6) * 7)) * 8) * 9))
1 * ((2 - 3) - ((4 * (((5 - 6) * 7) * 8)) * 9))
1 * ((2 - 3) - (4 * ((((5 - 6) * 7) * 8) * 9)))
1 * ((2 - 3) - ((((4 / (5 - 6)) * 7) * 8) * 9))
1 * ((2 - 3) - (((4 / (5 - 6)) * (7 * 8)) * 9))
1 * ((2 - 3) - (((4 / (5 - 6)) * 7) * (8 * 9)))
1 * ((2 - 3) - (((4 / ((5 - 6) / 7)) * 8) * 9))
1 * ((2 - 3) - ((4 / (5 - 6)) * ((7 * 8) * 9)))
1 * ((2 - 3) - ((4 / (5 - 6)) * (7 * (8 * 9))))
1 * ((2 - 3) - ((4 / ((5 - 6) / (7 * 8))) * 9))
1 * ((2 - 3) - ((4 / ((5 - 6) / 7)) * (8 * 9)))
1 * ((2 - 3) - ((4 / (((5 - 6) / 7) / 8)) * 9))
1 * ((2 - 3) - (4 / ((5 - 6) / ((7 * 8) * 9))))
1 * ((2 - 3) - (4 / ((5 - 6) / (7 * (8 * 9)))))
1 * ((2 - 3) - (4 / (((5 - 6) / (7 * 8)) / 9)))
1 * ((2 - 3) - (4 / (((5 - 6) / 7) / (8 * 9))))
1 * ((2 - 3) - (4 / ((((5 - 6) / 7) / 8) / 9)))
((1 * (2 + 3)) - (4 - (5 * 6))) * ((7 * 8) + 9)
(1 - (((2 - (3 * 4)) + 5) * 6)) * ((7 * 8) + 9)
((1 * (2 + ((3 + 4) * 5))) - 6) * ((7 * 8) + 9)
((1 * 2) - ((3 * (4 + 5)) + 6)) * (7 - (8 * 9))
1 * ((((2 * (3 + ((4 * 5) * 6))) + 7) * 8) - 9)
1 * ((((2 * (3 + (4 * (5 * 6)))) + 7) * 8) - 9)
(1 - ((2 + 3) * ((4 - 5) * 6))) * ((7 * 8) + 9)
(1 - 2) * ((3 - (4 + (5 * 6))) * ((7 * 8) + 9))
(1 - ((2 - ((3 * 4) - 5)) * 6)) * ((7 * 8) + 9)
(1 - 2) * (((3 - 4) - (5 * 6)) * ((7 * 8) + 9))
(((((1 * 2) - 3) - 4) * 5) - 6) * (7 - (8 * 9))
((((1 * 2) - (3 + 4)) * 5) - 6) * (7 - (8 * 9))
((1 * (2 - (3 * (4 + 5)))) - 6) * (7 - (8 * 9))
(((1 - (2 * 3)) * 4) - (5 + 6)) * (7 - (8 * 9))
((((1 * (2 - 3)) - 4) * 5) - 6) * (7 - (8 * 9))
((((1 / (2 - 3)) - 4) * 5) - 6) * (7 - (8 * 9))
(1 - (((2 + 3) * (4 - 5)) * 6)) * ((7 * 8) + 9)
(((1 * (2 - (3 + 4))) * 5) - 6) * (7 - (8 * 9))
((1 * ((2 - (3 + 4)) * 5)) - 6) * (7 - (8 * 9))
(((1 * ((2 - 3) - 4)) * 5) - 6) * (7 - (8 * 9))
((1 * (((2 - 3) - 4) * 5)) - 6) * (7 - (8 * 9))
(1 - (((2 + 3) / (4 - 5)) * 6)) * ((7 * 8) + 9)
(1 - ((2 + 3) / ((4 - 5) / 6))) * ((7 * 8) + 9)
(((1 - (2 + 3)) / 4) - (5 * 6)) * (7 - (8 * 9))
((((1 - 2) - 3) / 4) - (5 * 6)) * (7 - (8 * 9))
(1 * (((2 + 3) + (4 * 5)) + 6)) * ((7 * 8) + 9)
(1 * ((2 + (3 + (4 * 5))) + 6)) * ((7 * 8) + 9)
(1 * ((2 + 3) + ((4 * 5) + 6))) * ((7 * 8) + 9)
(1 * (2 + ((3 + (4 * 5)) + 6))) * ((7 * 8) + 9)
(1 * (2 + (3 + ((4 * 5) + 6)))) * ((7 * 8) + 9)
1 * ((((2 + 3) + (4 * 5)) + 6) * ((7 * 8) + 9))
1 * (((2 + (3 + (4 * 5))) + 6) * ((7 * 8) + 9))
1 * (((2 + 3) + ((4 * 5) + 6)) * ((7 * 8) + 9))
1 * ((2 + ((3 + (4 * 5)) + 6)) * ((7 * 8) + 9))
1 * ((2 + (3 + ((4 * 5) + 6))) * ((7 * 8) + 9))
(1 * ((2 + (3 - 4)) + (5 * 6))) * ((7 * 8) + 9)
(1 * (2 + ((3 - 4) + (5 * 6)))) * ((7 * 8) + 9)
1 * (((2 + (3 - 4)) + (5 * 6)) * ((7 * 8) + 9))
1 * ((2 + ((3 - 4) + (5 * 6))) * ((7 * 8) + 9))
(1 * ((((2 + 3) * 4) + 5) + 6)) * ((7 * 8) + 9)
1 * (((((2 + 3) * 4) + 5) + 6) * ((7 * 8) + 9))
(1 * (((2 + 3) - 4) + (5 * 6))) * ((7 * 8) + 9)
1 * ((((2 + 3) - 4) + (5 * 6)) * ((7 * 8) + 9))
(1 * (2 + (3 - (4 - (5 * 6))))) * ((7 * 8) + 9)
1 * ((2 + (3 - (4 - (5 * 6)))) * ((7 * 8) + 9))
(1 * (2 + (((3 + 4) * 5) - 6))) * ((7 * 8) + 9)
1 * ((2 + (((3 + 4) * 5) - 6)) * ((7 * 8) + 9))
(1 * (((2 + 3) * 4) + (5 + 6))) * ((7 * 8) + 9)
1 * ((((2 + 3) * 4) + (5 + 6)) * ((7 * 8) + 9))
(((1 * (2 / (3 * 4))) + 5) * 6) * ((7 * 8) + 9)
(((1 * ((2 / 3) / 4)) + 5) * 6) * ((7 * 8) + 9)
((((1 * 2) / (3 * 4)) + 5) * 6) * ((7 * 8) + 9)
(1 * ((2 / (3 * 4)) + 5)) * (6 * ((7 * 8) + 9))
1 * (((2 / (3 * 4)) + 5) * (6 * ((7 * 8) + 9)))
((((1 * (2 / 3)) / 4) + 5) * 6) * ((7 * 8) + 9)
(((((1 * 2) / 3) / 4) + 5) * 6) * ((7 * 8) + 9)
(1 * (((2 / 3) / 4) + 5)) * (6 * ((7 * 8) + 9))
1 * ((((2 / 3) / 4) + 5) * (6 * ((7 * 8) + 9)))
(1 * ((2 + 3) - (4 - (5 * 6)))) * ((7 * 8) + 9)
1 * (((2 + 3) - (4 - (5 * 6))) * ((7 * 8) + 9))
(1 * ((2 + ((3 + 4) * 5)) - 6)) * ((7 * 8) + 9)
1 * (((2 + ((3 + 4) * 5)) - 6) * ((7 * 8) + 9))
(1 * (2 - ((3 * (4 + 5)) + 6))) * (7 - (8 * 9))
1 * ((2 - ((3 * (4 + 5)) + 6)) * (7 - (8 * 9)))
((1 - 2) * (3 - (4 + (5 * 6)))) * ((7 * 8) + 9)
((1 - 2) * ((3 - 4) - (5 * 6))) * ((7 * 8) + 9)
(1 * ((2 - (3 * (4 + 5))) - 6)) * (7 - (8 * 9))
1 * (((2 - (3 * (4 + 5))) - 6) * (7 - (8 * 9)))
(1 * (((2 - (3 + 4)) * 5) - 6)) * (7 - (8 * 9))
1 * ((((2 - (3 + 4)) * 5) - 6) * (7 - (8 * 9)))
(1 * ((((2 - 3) - 4) * 5) - 6)) * (7 - (8 * 9))
1 * (((((2 - 3) - 4) * 5) - 6) * (7 - (8 * 9)))
((1 * ((2 / (3 * 4)) + 5)) * 6) * ((7 * 8) + 9)
(1 * (((2 / (3 * 4)) + 5) * 6)) * ((7 * 8) + 9)
1 * ((((2 / (3 * 4)) + 5) * 6) * ((7 * 8) + 9))
((1 * (((2 / 3) / 4) + 5)) * 6) * ((7 * 8) + 9)
(1 * ((((2 / 3) / 4) + 5) * 6)) * ((7 * 8) + 9)
1 * (((((2 / 3) / 4) + 5) * 6) * ((7 * 8) + 9))
$\endgroup$
6
  • 1
    $\begingroup$ Hey David, user 'mikeonly' has insufficient reputation to comment here. He has requested in chat that someone contact you to ask if he could see your Mathematica code used above. Could we have a pastebin link perhaps? Thanks David. $\endgroup$
    – user142198
    Jan 2, 2015 at 11:09
  • $\begingroup$ Like, DAMN. Should be accepted. $\endgroup$ Jan 2, 2015 at 11:24
  • $\begingroup$ @Committingtoachallenge Sure! I'll have to warn @mikeonly that it's pretty rough around the edges, as I wasn't planning on including it with my answer. The gist is that I generate a list of all full binary trees with nine leaves, replace those leaves with the numbers 1-9 (stored in enumeratedTrees), generate all 8-tuples of the operations $+,-,\times,\div$ (stored in operatorPermutations), and replace the vertices in each tree with each 8-tuple of operations. Then, I Select[] the ones that evaluate to 2015 and stick them all in a list (solutions)... $\endgroup$ Jan 2, 2015 at 11:24
  • $\begingroup$ ...after which I stringify[] them into the format you see above. On my system, it takes about 40 minutes to check all 65536 8-tuples. I'm sure this could be heavily optimized with the right data structures, but this was acceptable for the purposes of this question. Please let me know if you have any further questions. $\endgroup$ Jan 2, 2015 at 11:30
  • $\begingroup$ Wow, sounds impressive, thanks @David, Mike is happy. $\endgroup$
    – user142198
    Jan 2, 2015 at 11:31
23
$\begingroup$

I did this: $2015+9=2024$

$2024\div 8=253$

$253-7=246$

$246\div 6=41$

$41-5=36$

$36\div 4=9$

$9\div 3=3$

$3-2=1$

$1-1=0$.

Then $2015=(((1+2)\cdot 3\cdot 4+5)\cdot 6+7)\cdot 8-9$

$\endgroup$
4
  • $\begingroup$ Woah -- very cool! I've asked a question based on your response: math.stackexchange.com/questions/1089076/… $\endgroup$
    – emragins
    Jan 2, 2015 at 23:30
  • $\begingroup$ What technique did you use to find this? That's what the question is after, not just a solution. $\endgroup$ Jan 27, 2015 at 2:11
  • 1
    $\begingroup$ @curiousdannii: I just looked where I could get from 2015 with a 9, and from there with an 8, and so on, trying to get to 0. I figured I'd have to divide a lot to get the numbers down small enough. But it really was pretty ad hoc. There's a game out there called 'Krypto' that helped. (en.wikipedia.org/wiki/Krypto_%28game%29) $\endgroup$
    – paw88789
    Jan 27, 2015 at 3:05
  • $\begingroup$ @paw88789 You should edit your answer to include that :) $\endgroup$ Jan 27, 2015 at 3:07
15
$\begingroup$

$$ \begin{align} 2015 &=-1+2016\\ &=-1+224\times9\\ &=-1+28\times8\times9\\ &=-1+4\times7\times8\times9\\ &=-1+2\times2\times7\times8\times9\\ &=-1+2\times(-3+4-5+6)\times7\times8\times9\\ \end{align} $$ The "method" used above was to look for a number close to 2015 that has a number of factors. Use a combination of early integers to make up the difference and the rest to make up the factors. Here, $2015+1=2016=4\times7\times8\times9$. This reduces the problem to writing $4$ using $2,3,4,5,6$. A similar approach was used to break $4=2\times2$ where now the problem is reduced to writing $2$ using $3,4,5,6$.

$\endgroup$
5
  • 4
    $\begingroup$ -1+2 could be 1-2 $\endgroup$
    – Timtech
    Jan 2, 2015 at 13:36
  • 1
    $\begingroup$ @Timtech: I am not sure I understand: $$2015\ne1-2\times(-3+4-5+6)\times7\times8\times9$$ Did you mean something else? $\endgroup$
    – robjohn
    Jan 3, 2015 at 0:30
  • $\begingroup$ I do suppose order of operations makes a difference :) $\endgroup$
    – Timtech
    Jan 3, 2015 at 2:47
  • $\begingroup$ What technique did you use to find this? That's what the question is after, not just a solution. $\endgroup$ Jan 27, 2015 at 2:07
  • 1
    $\begingroup$ @curiousdannii: In generality, about the only way to solve this kind of problem is using brute force. In this special case, I noted that $2016$ is a multiple of $7\times8\times9$. This reduced the problem to writing $4$ using $2,3,4,5,6$. $\endgroup$
    – robjohn
    Jan 27, 2015 at 2:28
8
$\begingroup$

A simple brute force Python program could be used to find one possible solution, although finding all possible solutions would require permuting parentheses as well.

target = 2015

def rec(seq, total, ops):
    if (seq == 10):
        if total == target:
            print ops
        return
    rec(seq+1, total*seq, ops + ['*'])
    rec(seq+1, total-seq, ops + ['-'])
    rec(seq+1, total+seq, ops + ['+'])
    rec(seq+1, float(total)/seq, ops + ['/'])

rec(1, 0, [])

This program returns:

['+', '+', '*', '*', '+', '*', '+', '*', '-']

which is a possible solution to the problem

$(((1+2)*3*4+5)*6+7)*8-9 = 2015$

$\endgroup$
8
$\begingroup$

So here's the "general solution": A Python program that generates all expressions of the prescribed form (including parentheses) and evaluates them.

from __future__ import division
import itertools

def trees(n):
    trs = [set('n')]
    for i in range(1,n):
        s = set()
        for j in range(i):
            for l in trs[j]:
                for r in trs[i-j-1]:
                    s.add('(' + l + 'x' + r + ')')
        trs.append(s)
    return trs[-1]

def expressions(tree, n):
    for i in range(n):
        tree = tree.replace('n', str(i+1), 1)
    for ops in itertools.product(['+', '-', '*', '/'], repeat=n-1):
        t = tree
        for o in ops:
            t = t.replace('x', o, 1)
        yield t

n = 9
num = 2015

for tree in trees(n):
    for expr in expressions(tree, n):
        try:
            res = eval(expr)
            if res == num:
                print(str(num) + ' = ' + expr)
        except ZeroDivisionError:
            pass

Generating the parentheses is not a trivial task. This script generates "skeleton formulas" of the form ((nxn)xn), where n is a placeholder for a number and x is a placeholder for an operator, via dynamic programming (binary tree part taken from https://stackoverflow.com/a/12294488), then substitutes.

This is a very powerful approach. The program generates dozens of solutions in a matter of minutes (though not all of them are distinct after removing superfluous parentheses), e.g.

2015 = ((1-2)-((((3+((4-5)-6))*7)*8)*9))
2015 = ((1-2)-((((3*((4-5)-6))-7)*8)*9))
2015 = ((((1*2)+3)+((4*5)+6))*((7*8)+9))
2015 = ((1+((2*(3-4))-(5*6)))*(7-(8*9)))
2015 = ((1+((2/(3-4))-(5*6)))*(7-(8*9)))
2015 = ((1*(((2*(3+(4*(5*6))))+7)*8))-9)
2015 = (1*((2*(3-(4*(5*(6-(7*8))))))+9))
2015 = (((1*2)*(3+((4*5)*((6*7)+8))))+9)
2015 = ((1-2)-((3+((4-5)-6))*((7*8)*9)))
2015 = ((1*(((2*(3+((4*5)*6)))+7)*8))-9)
2015 = (((1*(((2+3)*4)+5))+6)*((7*8)+9))
2015 = (((1*(((2/3)/4)+5))*6)*((7*8)+9))
2015 = ((1*(2-3))-(4*(((5-6)*(7*8))*9)))
2015 = ((1*(2-3))-(4/(((5-6)/(7*8))/9)))
2015 = ((1/(2-3))-(4*(((5-6)*(7*8))*9)))
2015 = ((1/(2-3))-(4/(((5-6)/(7*8))/9)))
2015 = (((1*2)-3)-(((4*(5-6))*(7*8))*9))
2015 = (((1*2)-3)-(((4/(5-6))*(7*8))*9))
2015 = (((((1-2)-3)/4)-(5*6))*(7-(8*9)))

and can indeed be used to exhaust the entire search space and also solve a number of generalizations of the original problem.

As an example of the latter, the program reveals the existence of solutions with only the first eight digits:

$$2015 = 1-2-(3-4-5)\times6\times7\times8$$

and can also prove in just a few seconds that with only the first seven digits, no solution exists.

$\endgroup$
2
  • $\begingroup$ if '__main__' == __name__:? $\endgroup$
    – jpmc26
    Jan 2, 2015 at 22:17
  • 1
    $\begingroup$ @jpmc26: Useless since the script is not intended for importing anyway. $\endgroup$
    – user139000
    Jan 3, 2015 at 10:42
-1
$\begingroup$

A very easy approach can be

A) Find the prime factors of the number. That is,

$$5\times13\times31=2015$$

B) Express those prime factors as sum,difference,product and divison of numbers $1-9$, starting from the biggest prime factor to be easy. That is,

$$ (8-3)\times(7\cdot2-1)\times(9\cdot4-5)$$

Just one example. :)

$\endgroup$
1
  • $\begingroup$ I guess the problem insists on using the digits in their natural order, 1...9 $\endgroup$
    – Maesumi
    Apr 17, 2015 at 18:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .