# [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

## 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=5013
27+4986=5013
34+5978=6012
34+5987=6021
37+5984=6021
38+5974=6012
43+5978=6021
47+2968=3015
48+2967=3015
48+5973=6021
56+1978=2034
56+1987=2043
57+1986=2043
58+1976=2034
64+2987=3051
65+1978=2043
67+2948=3015
67+2984=3051
68+1975=2043
68+2947=3015
73+5948=6021
74+5938=6012
75+1968=2043
76+1958=2034
78+1956=2034
78+1965=2043
78+5934=6012
78+5943=6021
84+2967=3051
84+5937=6021
86+1957=2043
86+4927=5013
87+1956=2043
87+2964=3051
87+4926=5013
87+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=1035
249+786=1035
264+789=1053
269+784=1053
284+769=1053
286+749=1035
289+746=1035
289+764=1053
324+765=1089
325+764=1089
342+756=1098
346+752=1098
347+859=1206
349+857=1206
352+746=1098
356+742=1098
357+849=1206
359+847=1206
364+725=1089
365+724=1089
423+675=1098
425+673=1098
426+879=1305
429+876=1305
432+657=1089
437+589=1026
437+652=1089
439+587=1026
452+637=1089
457+632=1089
473+589=1062
473+625=1098
475+623=1098
476+829=1305
479+583=1062
479+826=1305
483+579=1062
487+539=1026
489+537=1026
489+573=1062
537+489=1026
539+487=1026
573+489=1062
579+483=1062
583+479=1062
587+439=1026
589+437=1026
589+473=1062
623+475=1098
624+879=1503
625+473=1098
629+874=1503
632+457=1089
637+452=1089
652+437=1089
657+432=1089
673+425=1098
674+829=1503
675+423=1098
679+824=1503
724+365=1089
725+364=1089
742+356=1098
743+859=1602
746+289=1035
746+352=1098
749+286=1035
749+853=1602
752+346=1098
753+849=1602
756+342=1098
759+843=1602
764+289=1053
764+325=1089
765+324=1089
769+284=1053
784+269=1053
786+249=1035
789+246=1035
789+264=1053
824+679=1503
826+479=1305
829+476=1305
829+674=1503
843+759=1602
847+359=1206
849+357=1206
849+753=1602
853+749=1602
857+349=1206
859+347=1206
859+743=1602
874+629=1503
876+429=1305
879+426=1305
879+624=1503