# Can you complete the expression $2 \underline{ }\, \underline{ }\, \underline{ } \,\underline{ } 5 = 2015$?

Can you complete the expression

$$2 \underline{ } \, \underline{ }\, \underline{ } \, \underline{ } 5 = 2015$$

and make it correct by replacing two underscores with a selection of the operational symbols $$+, - , /, \times$$ and the other two underscores with digits $$0,1,\ldots,9$$?

I have been working on this problem for quite a while now where my main strategy has simply been trial and error. However, I still can't seem to find a combination of operational symbols and digits where the result gives me 2015. If this is in fact not possible I would greatly appreciate an explanation and if it is possible, I would greatly appreciate an explanation of how you were able to solve it.

Thank you.

• $2 \cdot 9\cdot 95=1710<2015$ so I don't see how this is possible using exactly two operations and two digits.
– Surb
Aug 4, 2015 at 8:48
• Maybe something like 2{10^2(+3)}x5 derived with the gauss law instead Aug 4, 2015 at 19:17
• Maybe this is looking for cheating answers, like writing the 1 in 2010+5 as a rotated minus sign?
– hvd
Aug 4, 2015 at 21:02
• What if we relax the condition by saying that $2$ and $5$ can be anywhere (but still with two operators)? Aug 4, 2015 at 21:56
• Do they have to be numbers? If we use + as text concatenation (as in SQL, for example) then 2+01+5=2015. Aug 5, 2015 at 6:24

Exactly two underscores must be occupied by operators. Furthermore, no two operators can be placed adjacently, as this would be syntactically meaningless. Hence, there are only three possible arrangements of digit and operator positions:

• $2$ # @ # @ $5$
• $2$ @ # @ # $5$
• $2$ @ # # @ $5$

For each case, we choose the digits and operators that give the largest possible output, to see if it actually possible to reach the required neighborhood of values.

By inspection, I think it is fairly obvious that for each of the three cases above, filling the blanks with 9's and multiplication in the indicated positions (# for number, @ for operator) yields the largest possible output for each case:

• $2 9 \times 9 \times 5 = 1305$
• $2 \times 9 \times 9 5 = 1710$
• $2 \times 9 9 \times 5 = 990$

Any other digits or operators decrease the output, hence it is not possible to reach the neighborhood of $2015$, and therefore (I'm quite sure) the task is not possible.

• no two operators can be placed adjacently, as this would be syntactically meaningless It is meaningless, but still possible. See my answer Aug 4, 2015 at 19:32

No where in the puzzle forces us to interpret the digits as decimal numbers.
In base $8$, we have: $$21 \times +75 = 2015$$

• Well it does say "digits 0, 1, ... 9", that implies decimal. Aug 5, 2015 at 17:02
• @Cimbali, not really. It means if you ever use digit $8$ or $9$, then you cannot interpret the strings as octals. Aug 6, 2015 at 0:01
• It implies decimal, but it's not overtly stated. You could choose a base higher than 10 with the obvious consequence that you'd be restricted to using only the 1st 10 digits of that base. Aug 6, 2015 at 14:18

This is not possible, the largest number we can make using two operations and two digits is given by $$2 \cdot 9\cdot 95=1710<2015$$ so this problem has no solution stated as such. Of course if you relax the condition 2 operations-2 digits then, as proposed by 5xum (who proposed 2010+5), it is much easier.

• a different way of relaxing would be to include "^" (power) into the operations allowing for much greater numbers. However, I havent found a solution including this
– Bort
Aug 4, 2015 at 8:53
• @Bort We have 2^10+5=1029<2015<2043=2^11-5 and 29+4^5=1053<2015<3145=20+5^5 so it seems also impossible when allowing ^
– Surb
Aug 4, 2015 at 9:03
• Can confirm this, wrote some code to do the work: pastebin.com/DJP8U9iF Aug 4, 2015 at 9:04
• @surb : okay i should have been wordier.. This the exact same argumentation I so eloquently phrased with "havent found a solution". But thanks for clarifying.
– Bort
Aug 4, 2015 at 9:06
• @simonzack Could you add which language this is? (looks like python to me, but then I would guess some includes are missing)
– Bort
Aug 4, 2015 at 9:07

The puzzle does not restrict the operations to binary, so using + as a unary operator opens up even more possibilities and allows to reach higher numbers. It seemed promising at first, but sadly none of the possibilities is 2015. Here's a table:

$$2\mathrm{X} \times +\mathrm{Y}5$$ • good out-of-the-box thinking! One should consider $2XY\times +5$ and $2\times XY5$ as well. The latter gives multiples of $10$, the former requires $2XY=402$ though Aug 4, 2015 at 21:06
• @HagenvonEitzen True, but the largest it can get is $2 \times +995 = 1990$ Aug 4, 2015 at 21:22

# Brute force solution

I originally wrote the solution for 5 slots, with only 4 slots this approach proves that only two solution candidates appear: 2010+5 and 2020-5. Obviously these don't match the criterium so it is proved that no solution exists. For illustration I will hereby show how I found the solution for when there are 5 slots.

## Approach

It can easily be seen that there there are just a limited number of possibilities here. A simple upper bound can be found by considering that each slot can be occupied by 14 different characters, and there are 5 slots. As such we can simply try roughly half a million possibilities (14^5 to be exact) and evaluate the solution.

## Matlab code

v = ['0':'9' '+' '-' '*' '/'];

results = [];
for a=v
for b=v
for c=v
for d=v
for e=v
x = false;
s = ['x = 2' a b c d e '5 == 2015;'];
try
eval(s);
catch
end
if x
results = [results; s];
end
end
end
end
end
end


## Results

x = 2000+15 == 2015;
x = 2010+05 == 2015;
x = 2010++5 == 2015;
x = 2010--5 == 2015;
x = 2020+-5 == 2015;
x = 2020-05 == 2015;
x = 2020-+5 == 2015;
x = 2030-15 == 2015;
x = 2040-25 == 2015;
x = 2050-35 == 2015;
x = 2060-45 == 2015;
x = 2070-55 == 2015;
x = 2080-65 == 2015;
x = 2090-75 == 2015;
x = 20+1995 == 2015;
x = 2100-85 == 2015;
x = 2110-95 == 2015;


## Conclusion

Most combinations do not meet the restriction of having exactly 2 operators, but some do. My personal favorite which I would personally consider to be the answer:

2010--5 == 2015

• There aren't five slots though, there are only four.
– hvd
Aug 5, 2015 at 10:35
• Cue someone complaining about eval in 5..... 4..... 3..... Aug 5, 2015 at 10:52
• @hvd Incredible, I updated the answer slightly to match the question. I just ran the code for 4 slots but unfortunately no solution exists. Aug 5, 2015 at 11:11
• @immibis Perhaps I can state premptively that I am aware that eval should be avoided in most situations, but that I think this is a proper usage of eval. Aug 5, 2015 at 11:16
• @DennisJaheruddin False. I modified your code for the 4 slot case, and you get 2010+5 and 2020-5. Granted this isn't a solution to the original problem, but it is a solution to the one you present, with relaxed conditions. Still +1. I like this code. Aug 5, 2015 at 16:56

As shown by the other answers, this problem is impossible with two operators and two regular digits. So we'll have to take liberties:

Taking the liberty of an extra possible operator gets us closer, as shown by Surb's comment to his own answer. If we take another operator than what he suggests, and include the factorial operator, then we get very close:

$$2 \cdot 7! / 5 = 2016$$

But there is another option if we don't restrict ourselves to base 10. If we can write either the number 1000 or 1010 with 2 'digits', then we can solve this problem quite easily. This requires a base of at least 32, since x^2 > 1010. Fortunately, base 32 is fairly straightforward if you're used to hexadecimal notation. It only extends to V, which is equal to 31 in base 10.

$$1000 = 31 \cdot 32 + 8 = V8$$

Therefore, if we accept base 32 as an allowed relaxation to your rule:

$$2 \cdot V8 + 5 = 2015$$

• While this is an interesting attempt, I believe there is one fundamental flaw. We can't pick and choose what to consider base 10 and what to consider base 32. On the left hand side you are computing base 32, so the right hand side would need to be base 32 as well but $2*V8+5$ is significantly less than $2015$ base 32(which is $2*32^3+32+5$ in base 10.) Aug 4, 2015 at 12:38
• That is a very valid point. It then depends whether you want, in base 32, the value $2015$ or the value $1UV$ Aug 4, 2015 at 12:45