Fill in the blanks with 1-9: ((.-.)^.)*..+.-.-.-.= 100

This is a math puzzle asked by a teacher of mine that I can't figure out. The puzzle is to fill in all blanks with digits 1-9, using each only once, to equal 100. The equation is as follows: (dots are unknown numbers)

((.-.)^.)*..+.-.-.-.= 100.

The two dots in a row symbolize a 2-digit number.
^. symbolizes an exponent to an unknown number.

I found this solution

((9-5)^1)*28+4-3-7-6

Idea

was to get as close to 100 as possible with the first 3 operations. I did a 5 minutes trial and error to reach this.

Some screenshots of T&E to prove that it was non programmatic approach :)

...

• Rot13(V sbhaq sbhegrra fbyhgvbaf cebtenzzngvpnyyl (qvfpneqvat qvssrerag beqrevatf bs gur ynfg guerr fhogenpgvbaf) naq nyy bs gurz unir rkcbarag bar). Apr 16 at 12:16

You can solve that by thinking about boundaries:

I'll use the equation as (a-b)^c * de+f-g-h-i=100 to simplify the notation. The lowest value (f-g-h-i) can get is (1-9-8-7) = -23 and the highest is (9-1-2-3) = 3.

This means 100-3 <= (a-b)^c * de <= 100+23

Now let's divide it all by de. This leads us to 97/de <= (a-b)^c <= 123/de

The lowest value "de" can be is 12. This means our highest value for (a-b)^c is <= 123/12 which is <=10. So all possible values for (a-b)^c in this scenario are:
2^2 = 4;
3^3 = 9;
2^3 = 8;
1^c = 1;
(a-b)^1 = (a-b);

Thinking about the greatest value "de" can be (98), our lowest value in 97/de <= (a-b)^c means 1 <= (a-b)^c , which doesn't tell us much.

Now lets list all possible combinations of (a-b)^c * de thinking about those boundaries and taking the cases that don't involve the number 1 in c:

1^c * 98 = 98 → no solution because the highest for (f-g-h-i) would become (7-2-3-4) = -2. Which makes the (a-b)^c * de = 102 which is greater than 98.

All other combinations that don't use c = 1:
3^2 * 12 = 117 → not possible because uses 2 twice (c and e);
3^2 * 13 = 117 → no solution (same logic as 1^c * 98);
2^3 * 13 = 104 → no solution (same logic as 1^c * 98);
2^3 * 14 = 112 → no solution (same logic as 1^c * 98);
2^3 * 15 = 120 → no solution (same logic as 1^c * 98);
2^2 * 25 = 100 → not possible because uses 2 twice (c and d);
2^2 * 26 = 104 → not possible because uses 2 twice (c and d);
2^2 * 27 = 108 → not possible because uses 2 twice (c and d);
2^2 * 28 = 112 → not possible because uses 2 twice (c and d);
2^2 * 29 = 116 → not possible because uses 2 twice (c and d);
This means c = 1

Now let's update our boundaries: 100-(f-g-h-i) <= (a-b)^c * de <= 100+(f-g-h-i) → 100-9+2+3+4 <= (a-b)^1 * de <= 100-2+9+8+7 → 100 <= (a-b)^1 * de <= 122

Now you can make all the combinations that don't have de with a number 1 that fit in our (a-b)^1 < 10 and that don't have repeating digits for de (17 values in total):
4^1 * 26 = 104;
4^1 * 27 = 108 → parity problem (explained below);
4^1 * 28 = 112;
4^1 * 29 = 116 → parity problem;
3^1 * 34 = 102;
3^1 * 35 = 105;
3^1 * 36 = 108;
3^1 * 37 = 111;
3^1 * 38 = 114;
3^1 * 39 = 117;
2^1 * 52 = 104 → parity problem;
2^1 * 53 = 106;
2^1 * 54 = 108 → parity problem;
2^1 * 56 = 112 → parity problem;
2^1 * 57 = 114;
2^1 * 58 = 116 → parity problem;
2^1 * 59 = 118;

Now let's look at parity. Let's take 4^1 * 27 = 108 for example. To make a-b = 4, I need to use two values of the same parity. Two odds or two evens. Then I'll be left to make (f-g-h-i) to be even (has to be -8 to make 108). And I used an odd already for the c=1 and e =7 (reminder that de = 27). This leaves me with either 1 or 3 odd numbers for (f-g-h-i), which will never make -8. The same applies to all even (a-b) with de using one odd. (My first attempt had a logic mistake here. I fixed it thanks to @WeatherVane)

Our list now becomes (you can now solve this manually or continue reading):
4^1 * 26 = 104; → out of boundaries (explained below);
4^1 * 28 = 112; → two solutions
3^1 * 34 = 102; → out of boundaries (explained below);
3^1 * 35 = 105; → one solution
3^1 * 36 = 108; → two solutions
3^1 * 37 = 111; → two solutions
3^1 * 38 = 114; → two solutions
3^1 * 39 = 117; → two solutions
2^1 * 53 = 106; → out of boundaries (explained below);
2^1 * 57 = 114; → two solutions
2^1 * 59 = 118; → one solution

Now lets try to make (a-b)^c = 4, 3 or 2:

To make 4, you'll have to use the pairs 6-2; 7-3; 8-4; 9-5.

For 4^1 * 26 = 104, the highest you can go for (f-g-h-i) would be 9-5-7-3 = -6. So 100-(f-g-h-i) <= (a-b)^c * de becomes 106 <= (a-b)^1 * 26, but you needed (a-b)^1 * 26 to be 104 instead. So this is invalid.

For 4^1 * 28 = 112, you can make a-b with 7-3 or 9-5. So you have two solutions here: "(7-3) * 28+6-9-5-4" "(9-5) * 28+4-6-7-3"

To make 3, you'll have to use 5-2; 7-4; 8-5; 9-6. You can't use 6-3 because d uses 3.

For 3^1 * 34 = 102, the highest you can go for (f-g-h-i) would be 9-7-2-6 = -6. So 100-(f-g-h-i) <= (a-b)^c * de becomes 106 <= (a-b)^1 * 34, but you needed (a-b)^1 * 34 to be 102 instead. So this is invalid.

For 3^1 * 35 = 105, the solutions is "(9-6) * 35+8-2-4-7".

For 3^1 * 36 = 108, the solutions are "(8-5) * 36+7-4-9-2" and "(7-4) * 36+8-5-9-2". The a-b 5-2 pair fails here.

For 3^1 * 37 = 111, the solutions are "(9-6) * 37+4-2-5-8" and "(5-2) * 37+8-4-6-9". The a-b 7-4 pair fails here.

For 3^1 * 38 = 114, the solutions are "(5-2) * 38+6-4-7-9" and "(9-6) * 38+2-4-5-7". The a-b 7-4 pair fails here.

For 3^1 * 39 = 117, the solutions are "(7-4) * 39+2-5-6-8" and "(5-2) * 39+4-6-7-8". The a-b 9-6 pair fails here.

To make 2, you'll have to use 4-2; 5-3; 6-4; 7-5; 8-6; 9-7. You can't use 5-3 nor 7-5 because d uses 5.

For 2^1 * 53 = 106, the highest you can go for (f-g-h-i) would be 9-7-4-6 = -8. So 100-(f-g-h-i) <= (a-b)^c * de becomes 108 <= (a-b)^1 * 34, but you needed (a-b)^1 * 53 to be 106 instead. So this is invalid.

For 2^1 * 57 = 114, the solutions are
"(8-6) * 57+2-4-3-9"
"(4-2) * 57+6-8-3-9".

For 2^1 * 59 = 118, the solution is "(4-2) * 59+3-7-6-8"

So the solutions are:
"(9-5)^1 * 28+4-6-7-3"
"(7-3)^1 * 28+6-9-5-4"
"(9-6)^1 * 35+8-2-4-7"
"(8-5)^1 * 36+7-4-9-2"
"(7-4)^1 * 36+8-5-9-2"
"(9-6)^1 * 37+4-2-5-8"
"(5-2)^1 * 37+8-4-6-9"
"(9-6)^1 * 38+2-4-5-7"
"(5-2)^1 * 38+6-4-7-9"
"(7-4)^1 * 39+2-5-6-8"
"(5-2)^1 * 39+4-6-7-8"
"(8-6)^1 * 57+2-4-3-9"
"(4-2)^1 * 57+6-8-3-9"
"(4-2)^1 * 59+3-7-6-8"

Thanks Weather Vane for providing the complete final answer. I fixed some mistaken leaps in my logic thanks to that.

• I have shown the solutions you referred to in an "answer". Apr 16 at 17:20
• Welcome! I have edited your answer to add line breaks where they appear to have been intended. I recommend further editing to combine some of the smaller spoiler blocks. Apr 16 at 17:52
• Great answer. Very well explained. Apr 16 at 18:02
• "2^3 * 14 = 112 → no solution (same logic as 1^c * 98);" - actually wrong, the highest for f-g-h-i here is 9-7-5-2=-5, and the lowest is low enough to pass the bounds check. Yet there's problem with parity, as taking 1, 3, 4 and two of equal parity out makes f-g-h-i odd. Likely some of the other entries under (a-b)^2*1x are also listed wrong for the different reason. Say 2^3*15 passes both range and parity check (f-g-h-i ranges from -22 to -4), so only by checking all possibilities one can find out if there are no solutions. Apr 17 at 11:40
• It's probably worth mentioning that the full list of solutions is much longer than the final block since for any solution, g, h, and i will be interchangeable. Apr 17 at 19:14

I could get downvoted for solving programmatically instead of logically, but Lucas P. Luiz has asked about my solutions, so I will show them here, just for that reason. I don't consider that I solved the puzzle per se.

$$(4-2)^1 \times 57+6-3-8-9 = 100$$
$$(4-2)^1 \times 59+3-6-7-8 = 100$$
$$(5-2)^1 \times 37+8-4-6-9 = 100$$
$$(5-2)^1 \times 38+6-4-7-9 = 100$$
$$(5-2)^1 \times 39+4-6-7-8 = 100$$
$$(7-3)^1 \times 28+6-4-5-9 = 100$$
$$(7-4)^1 \times 36+8-2-5-9 = 100$$
$$(7-4)^1 \times 39+2-5-6-8 = 100$$
$$(8-5)^1 \times 36+7-2-4-9 = 100$$
$$(8-6)^1 \times 57+2-3-4-9 = 100$$
$$(9-5)^1 \times 28+4-3-6-7 = 100$$
$$(9-6)^1 \times 35+8-2-4-7 = 100$$
$$(9-6)^1 \times 37+4-2-5-8 = 100$$
$$(9-6)^1 \times 38+2-4-5-7 = 100$$

results = 14

This is the C code.

#include <stdio.h>

int used[10];
int hist[10];
int results;

long long powN (long long num, unsigned power)
// calculate num^power with exponentiation
{
long long prod = 1;
while (power) {
if (power & 1)
prod *= num;
num *= num;
power >>= 1;
}
return prod;
}

void recur(int level, int first)
// permute unique digits, with last 3 in ascending order
{
if(level == 9) {
if(powN(hist[0] - hist[1], hist[2]) * (hist[3]*10 + hist[4]) + hist[5] - hist[6] - hist[7] - hist[8] == 100) {
printf(">! $$(%d-%d)^%d \\times %d%d+%d-%d-%d-%d = 100$$  \n", hist[0], hist[1], hist[2], hist[3], hist[4], hist[5], hist[6], hist[7], hist[8]);
results++;
}
return;
}
for(int n=first; n<=9; n++) {
if(!used[n]) {
used[n] = 1;
hist[level] = n;
recur(level + 1, level < 6 ? 1 : n + 1);
used[n] = 0;
}
}
}

int main(void)
{
recur(0, 1);
printf(">!  \n");
printf(">! results = %d  \n", results);
}

• Nice. You can may be add your code snippet :) Apr 16 at 18:03
• @Techidiot thanks, it's a rather brutal off-the-cuff program: I would have to better it and prepare it for publication! Apr 16 at 18:08
• @WeatherVane thanks! I managed to fix a logic leap I took in my answer thanks to you! Apr 16 at 18:20
• @Techidiot added the not-quite-so-ragged code. The exponentiation is a bit over-kill for a single-digit exponent, but... there it is. Apr 16 at 18:41
• "I could get downvoted for solving programmatically instead of logically" - well it does not have [no-computers] Apr 17 at 3:47