Suppose a, b, c, d, e, f, g, h are different digits in the range 1 – 8 which satisfy:
$\qquad \frac{b}{a}+\frac{\text{fgh}}{\text{cde}}=1$
How can I find their value? I tried
Solve[
{b/a + FromDigits[{f, g, h}]/FromDigits[{c, d, e}] == 1,
1 <= {a, b, c, d, e, f, g, h} <= 8,
Unequal @@ {a, b, c, d, e, f, g, h}},
{a, b, c, d, e, f, g, h},
Integers]
but Mathematica cannot get the result from this formulation.
Answer
Because there are only
8!
40320
combinations, we can test them all:
perm = Permutations@Range@8;
out = #2/#1 + FromDigits[{#6, #7, #8}]/FromDigits[{#3, #4, #5}] == 1 & @@@ perm;
pos = Flatten@Position[out, True]
{10534, 10679, 15991, 16333, 16963, 37736, 38041, 39464}
perm[[pos]]
{{3, 1, 6, 7, 8, 4, 5, 2}, {3, 1, 7, 8, 6, 5, 2, 4}, {4, 2, 3, 5, 6, 1, 7, 8}, {4, 2, 7, 1, 6, 3, 5, 8}, {4, 3, 6, 2, 8, 1, 5, 7}, {8, 4, 3, 5, 2, 1, 7, 6}, {8, 4, 7, 1, 2, 3, 5, 6}, {8, 6, 5, 7, 2, 1, 4, 3}}
Comments
Post a Comment