[0-9] digit puzzle
Sorry for the long delay between publishing articles. My illness has been catching up to me, and I’ve had a rough couple of weeks.
Puzzle
Here’s a fun little number puzzle that is easy to solve with a few lines of brute force code, but with a little thinking, and a pad and paper, can be solved pretty much by hand and some common sense.
Rearrange the digits [0-9] inclusive to make three numbers: x,y,z (No leading zeroes). These numbers should match the equality that x+y=z. Find all the solutions.
Use the digits [0-9] to make three numbers: x,y,z so that x+y=z
Advertisement:
Thinking
The first thing to think about is the number of significant digits. When you add two numbers together, at a minimum, you have to have at least the same number of digits, for the longest, as what you started with; (positive) numbers never get shorter by adding. This means the number of digits in z cannot be less than four. (For example, if z were three digits long, then either x or y would need to be at least four digits long, which makes no sense).
With other thinking, we see that z cannot have five (or more) digits. If z had five digits, then it would have need to have grown at least one digit (the max length of either x or y would be four digits, and the only way to grow the length of a number is with a carry). To convert a four-digit number to a five-digit number would require a cascading carry all across the entire number. In this puzzle, the maximum number of cascades that can occur to a four digit number by adding a single number is two, and this is where the second digit is a 9 (the least significant digit of x and y get added, which causes a carry to the next significant digit, which is a 9, and this can roll over once more, but then things get quenched as the max carry is a one - There are no more ways to propagate the carry). The number of digits in z, therefore, must be four.
The number of digits in z must be four.
This gives us only two patterns to consider. With z having four digits, then x and y are either {2,4} or {3,3} digits long.
{2,4}
Without loss of generality, and to reduce duplicates, I’ll assume x is the two-digit number.
Because every digit needs to be distinct, and both y and z are four digits, then the addition of x needs to cascade across the entire four-digit number so that most significant digit changes (changing every digit along the way). The only way that this can occur is when y is in the format D 9 ? ? so that the cascading carry rolls over the most significant digit of z giving a solution of the form (D+1) 0 ? ? From here it’s a simple exercise to permute the digits not used to create a pair of two-digit numbers that carry forward a one, and use distinct digits in their solutions too.
Here is a list of all the {2,4} solutions:
26+4987=501327+4986=501334+5978=601234+5987=602137+5984=602138+5974=601243+5978=602147+2968=301548+2967=301548+5973=602156+1978=203456+1987=204357+1986=204358+1976=203464+2987=305165+1978=204367+2948=301567+2984=305168+1975=204368+2947=301573+5948=602174+5938=601275+1968=204376+1958=203478+1956=203478+1965=204378+5934=601278+5943=602184+2967=305184+5937=602186+1957=204386+4927=501387+1956=204387+2964=305187+4926=501387+5934=6021
{3,3}
To convert two three-digit numbers into a four-digit number, there needs to be a carry to the most significant digit. (There are a couple of solutions that simple that simply cause this carry in the most significant digit, but most solutions cascade the carry).
Because of the limits of carry, the most significant digit for z will need to be 1.
You will quickly find patterns in pairs of digits, and their chiral solutions.
Here is a list of all the {3,3} solutions:
246+789=1035249+786=1035264+789=1053269+784=1053284+769=1053286+749=1035289+746=1035289+764=1053324+765=1089325+764=1089342+756=1098346+752=1098347+859=1206349+857=1206352+746=1098356+742=1098357+849=1206359+847=1206364+725=1089365+724=1089423+675=1098425+673=1098426+879=1305429+876=1305432+657=1089437+589=1026437+652=1089439+587=1026452+637=1089457+632=1089473+589=1062473+625=1098475+623=1098476+829=1305479+583=1062479+826=1305483+579=1062487+539=1026489+537=1026489+573=1062537+489=1026539+487=1026573+489=1062579+483=1062583+479=1062587+439=1026589+437=1026589+473=1062623+475=1098624+879=1503625+473=1098629+874=1503632+457=1089637+452=1089652+437=1089657+432=1089673+425=1098674+829=1503675+423=1098679+824=1503724+365=1089725+364=1089742+356=1098743+859=1602746+289=1035746+352=1098749+286=1035749+853=1602752+346=1098753+849=1602756+342=1098759+843=1602764+289=1053764+325=1089765+324=1089769+284=1053784+269=1053786+249=1035789+246=1035789+264=1053824+679=1503826+479=1305829+476=1305829+674=1503843+759=1602847+359=1206849+357=1206849+753=1602853+749=1602857+349=1206859+347=1206859+743=1602874+629=1503876+429=1305879+426=1305879+624=1503