Solving a cryptarithm
# /. Solve[{ 10^2 d + 10 e + f + 10^2 f + 10 e + f == 10^2 g + 10 h + h,
2 (10^2 k + 10 l + m) == 10^2 n + 10 k + l,
3 (10^2 a + 10 b + c) == 10^2 b + 10 b + b} ~ Join ~
Thread[0 <= # <= 9 &@#], #, Integers]& @ {a, b, c, d, e, f, g, h, k, l, m, n}
// Short[#, 6] &
{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 5, 2}, {0, 0, 0, 0, 0, 0, 0, 0, 2, 6, 3, 5}, {0, 0, 0, 0, 0, 0, 0, 0, 3, 6, 8, 7}, {0, 0, 0, 0, 0, 0, 0, 0, 4, 2, 1, 8}, {0, 0, 0, 0, 1, 1, 1, 2, 0, 0, 0, 0}, <<739>>, {1, 4, 8, 9, 0, 0, 9, 0, 0, 0, 0, 0}, {1, 4, 8, 9, 0, 0, 9, 0, 1, 0, 5, 2}, {1, 4, 8, 9, 0, 0, 9, 0, 2, 6, 3, 5}, {1, 4, 8, 9, 0, 0, 9, 0, 3, 6, 8, 7}, {1, 4, 8, 9, 0, 0, 9, 0, 4, 2, 1, 8}}
It yields the result instantanously. Mind Slot
( #
) appears here in the three contexts, thus we had to put the symbol &
in appropriate places where the pure functions end.
v = {100, 10, 1};
{#, Variables[List @@ #]} & /@
{
v.{d, e, f} + v.{f, e, f} == v.{g, h, h},
2*v.{k, l, m} == v.{n, k, l},
3*v.{a, b, c} == v.{b, b, b}
}
FindInstance[Join[{#}, Thread[10 > #2 > 0]], #2, Integers] & @@@ %
{{{d -> 3, e -> 3, f -> 3, g -> 6, h -> 6}}, {{k -> 2, l -> 6, m -> 3, n -> 5}}, {{a -> 1, b -> 4, c -> 8}}}