--- --- --- --- --- ---
| | | | | | | | |
--- --- + --- --- + --- ---
| | | | | | | | | |
--- --- --- --- --- ---
--- ---
| | | |
= --- ---
| | | |
--- ---
Fifty-seven matchsticks are laid out to form the above-mentioned sum, which is obviously incorrect.
Make the above sum correct by:
- Removing precisely two matchsticks.
- Removing precisely eight matchsticks.
LEGEND
• Each --- counts as
one stick.
• Each | counts as
one stick.
• Each + counts as
two sticks.
• The = counts as
two sticks.
Change the equation to 86-36+38=88 by removing the vertical stick from the first + and the top-left most vertical stick in the 9. That's 2 sticks removed.
For 8 sticks, change the equation to 8 6 - 3 6 + 3 4 = 8 4.
The removed amounts by character are 1 1 3 3.
In fact there are 341 ways of making a true equation by removing exactly 8 matchsticks (some have leading zeros as you can see below--255 remain if you exclude those with leading zero in the first summand or final total--the rest don't have any leading zeros.).
This section of code from the program will help understand the below solutions:
eqn='86+36+98==88';
conv={}; diff=0;
conv{8}= [[5,-2]; [2,-2];[3,-2];[4,-3];...
[7,-4];[6,-1];[9,-1];[1,-5];[0,-1]] ;
conv{6}= [[5,-1] ; [1,-4] ] ;
conv{3}= [[7,-2]; [1,-3] ] ;
conv{9}= [[5,-1]; [3,-1];[4,-2];...
[7,-3]; [1,-4]] ;
For example, an 8 is converted to a 5 by removing 2 sticks, to a 2 by removing 2 sticks, ..., to a 4 by removing 3 sticks, to a 7 by removing 4 sticks, ... . And of course a + changes to a - by removing one stick.
05+16+59=80
05+35+38=78
05+35-32=08
05+35-38=02
05+36+38=79
05+36+42=83
05+36+47=88
05+36+52=93
05+36+57=98
05+36-32=09
05+36-35=06
05+36-36=05
05+36-39=02
05-35+30=00
05-35+36=06
05-35+39=09
05-36+36=05
05-36+40=09
05-36+93=62
05-36+98=67
05-75+98=28
05-76+99=28
06+15+59=80
06+16+36=58
06+16+46=68
06+35+38=79
06+35+42=83
06+35+47=88
06+35+52=93
06+35+57=98
06+35-32=09
06+35-35=06
06+35-36=05
06+35-39=02
06+36+16=58
06+36+39=81
06+36+42=84
06+36+47=89
06+36+52=94
06+36+57=99
06+36-40=02
06+36-42=00
06-16+38=28
06-35+35=06
06-35+59=30
06-35+92=63
06-35+97=68
06-36+32=02
06-36+33=03
06-36+35=05
06-36+78=48
06-75+98=29
06-76+78=08
06-76+90=20
06-76+96=26
06-76+99=29
15+35+38=88
15+36+38=89
16+35+38=89
16+36+38=90
25+35+30=90
25+35+36=96
25+35+39=99
25+36+35=96
25+36-53=08
25+36-58=03
25-35+38=28
25-36+39=28
25-36+93=82
25-36+98=87
26+16+46=88
26+16+56=98
26+35+35=96
26+35-53=08
26+35-58=03
26+36+33=95
26+36+34=96
26+36-36=26
26+36-53=09
26+36-54=08
26+36-58=04
26+36-59=03
26+76-96=06
26-16+58=68
26-35+38=29
26-35+92=83
26-35+97=88
26-36+18=08
26-36+30=20
26-36+36=26
26-36+39=29
26-76+98=48
35+15+38=88
35+16+38=89
35+35+18=88
35+36+18=89
35-35+38=38
35-35+58=58
35-35+90=90
35-35+96=96
35-35+99=99
35-36+39=38
35-36+59=58
35-36+96=95
36+15+38=89
36+16+38=90
36+35+18=89
36+36+18=90
36+36-36=36
36-35+38=39
36-35+58=59
36-35+59=60
36-35+95=96
36-36+30=30
36-36+36=36
36-36+39=39
36-36+48=48
36-36+50=50
36-36+56=56
36-36+59=59
36-36+92=92
36-36+93=93
36-36+95=95
36-76+48=08
45-35+58=68
45-36+59=68
45-36+90=99
46-16+58=88
46-35+58=69
46-36+38=48
46-36+48=58
46-36+50=60
46-36+56=66
46-36+59=69
46-76+38=08
55+35-90=00
55-35+38=58
55-35+48=68
55-36+39=58
55-36+49=68
55-36+50=69
56+36-30=62
56+36-32=60
56+36-36=56
56+36-56=36
56-16+48=88
56-16+58=98
56-35+38=59
56-35+39=60
56-35+48=69
56-36+30=50
56-36+36=56
56-36+39=59
56-36+40=60
56-36+46=66
56-36+49=69
56-36+58=78
56-75+99=80
56-76+58=38
65+35-32=68
65+35-38=62
65+36-32=69
65+36-35=66
65+36-36=65
65+36-39=62
65+76-53=88
65+76-58=83
65-15+38=88
65-16+39=88
65-35+30=60
65-35+36=66
65-35+39=69
65-36+30=59
65-36+36=65
65-36+40=69
65-36+53=82
65-36+58=87
65-75+90=80
65-75+96=86
65-75+99=89
65-76+96=85
66+35-32=69
66+35-35=66
66+35-36=65
66+35-39=62
66+36-16=86
66+36-40=62
66+36-42=60
66+36-46=56
66+36-50=52
66+36-52=50
66+36-56=46
66+75-53=88
66+75-58=83
66+76-53=89
66+76-54=88
66+76-58=84
66+76-59=83
66-15+38=89
66-16+30=80
66-16+36=86
66-16+39=89
66-16+48=98
66-35+35=66
66-35+52=83
66-35+57=88
66-36+32=62
66-36+33=63
66-36+35=65
66-36+48=78
66-75+95=86
66-75+99=90
66-76+48=38
66-76+58=48
66-76+78=68
66-76+92=82
66-76+93=83
66-76+95=85
76-76+98=98
81-36+38=83
85+16-93=08
85+16-98=03
85+35-34=86
85+35-35=85
85+35-36=84
85+75-92=68
85+75-98=62
85+76-92=69
85+76-95=66
85+76-96=65
85+76-99=62
85-35+18=68
85-35+32=82
85-35+33=83
85-35+35=85
85-35+40=90
85-35+46=96
85-35+49=99
85-35-50=00
85-36+19=68
85-36+34=83
85-36+35=84
85-36+37=86
85-36+46=95
85-36-40=09
85-36-49=00
85-75+78=88
85-76+79=88
86+15-93=08
86+15-98=03
86+16-36=66
86+16-93=09
86+16-94=08
86+16-98=04
86+16-99=03
86+36-35=87
86+36-37=85
86+75-92=69
86+75-95=66
86+75-96=65
86+75-99=62
86+76-76=86
86-16+18=88
86-31+33=88
86-35+18=69
86-35+33=84
86-35+34=85
86-35+36=87
86-35+45=96
86-35-43=08
86-35-48=03
86-36+10=60
86-36+16=66
86-36+19=69
86-36+34=84
86-36+42=92
86-36+43=93
86-36+45=95
86-75+78=89
86-76+70=80
86-76+76=86
86-76+79=89
91+35-38=88
91+36-38=89
91+36-39=88
95+31-38=88
95+35-32=98
95+35-38=92
95+35-42=88
95+35-48=82
95+35-92=38
95+35-98=32
95+36-32=99
95+36-35=96
95+36-36=95
95+36-39=92
95+36-42=89
95+36-45=86
95+36-46=85
95+36-49=82
95+36-92=39
95+36-95=36
95+36-96=35
95+36-99=32
95+75-90=80
95-35+30=90
95-35+36=96
95-35+39=99
95-36+36=95
95-36+40=99
95-36-50=09
95-36-59=00
96+31-38=89
96+31-39=88
96+35-32=99
96+35-35=96
96+35-36=95
96+35-39=92
96+35-42=89
96+35-45=86
96+35-46=85
96+35-49=82
96+35-92=39
96+35-95=36
96+35-96=35
96+35-99=32
96+36-40=92
96+36-42=90
96+36-90=42
96+36-92=40
96-35+35=96
96-35-53=08
96-35-58=03
96-36+32=92
96-36+33=93
96-36+35=95
96-36-30=30
96-36-32=28
96-36-38=22
96-75+59=80
96-76+78=98
The program (the conv{} values show, for each old digit, the number of sticks removed to get to each of the possible replacement digits):
global eqn conv diff
eqn='86+36+98==88';
conv={}; diff=0;
conv{8}= [[5,-2]; [2,-2];[3,-2];[4,-3];...
[7,-4];[6,-1];[9,-1];[1,-5];[0,-1]] ;
conv{6}= [[5,-1] ; [1,-4] ] ;
conv{3}= [[7,-2]; [1,-3] ] ;
conv{9}= [[5,-1]; [3,-1];[4,-2];...
[7,-3]; [1,-4]] ;
changeIt(1)
function changeIt(psn)
global eqn conv eq diff
digID=eqn(psn);
if psn==1
eq=eqn;
end
if eq(psn)=='='
choices='=';
vals=0;
elseif eq(psn)=='+'
choices='-+';
vals=[-1,0];
else
table=conv{str2double(digID)};
choices=[digID char(strcat(string(table(:,1))))'];
vals=[0 table(:,2)'];
end
for i=1:length(choices)
eq(psn)=choices(i);
diff=diff+vals(i);
if psn==length(eqn)
if eval(eq) && abs(diff)<10
disp([string(eq) string(diff)])
end
else
changeIt(psn+1)
end
diff=diff-vals(i);
end
end
This lists all single-digit number of matchstick cases, from which a text editor finds those with 2 or 8, shown above.
|
Posted by Charlie
on 2022-06-21 11:33:02 |