How many solutions are there to $abc+def=ghi$, where $a,b,\ldots, h,i$ are distinct non-zero digits? I saw this problem posted by Google. Those posting in the comments found solutions using computer programming. I would like to know if there is an easier solution than trying every single combination.


Here's some simple and very fast MAGMA code which only tests permutations of $1,\ldots,9$, as opposed to all $9^9$ triplets of $3$-digit combinations.  It ran in $3.042$ seconds on my computer.
Z := {@ 1,2,3,4,5,6,7,8,9 @};
S := SymmetricGroup(9);
X := GSet(S,Z);
sol := [];
for s in S do
    Y := X^s;
    A := Y[1]*100 + Y[2]*10 + Y[3];
    B := Y[4]*100 + Y[5]*10 + Y[6];
    C := Y[7]*100 + Y[8]*10 + Y[9];
    if A + B eq C then
        Append(~sol,Y);
        end if;
    end for;

We can make this faster, actually, by noticing that $g+h+i$ must be exactly equal to $18$.  Furthermore, we can use a "carrying" method to rule out certain cases early.  The following runs in $1.982$ seconds.
Z := {@ 1,2,3,4,5,6,7,8,9 @};
S := SymmetricGroup(9);
X := GSet(S,Z);
sol := [];
for s in S do
    Y := X^s;
    if Y[7] + Y[8] + Y[9] eq 18 then
        u := Y[3] + Y[6];
        if u mod 10 eq Y[9] then
            v := Floor(u/10) + Y[2] + Y[5];
            if v mod 10 eq Y[8] then
                w := Floor(v/10) + Y[1] + Y[4];
                if w eq Y[7] then
                    Append(~sol,Y);
                    end if;
                end if;
            end if;
        end if;
    end for;

