\(TraditionalForm\`1\/23 + 4\/56 + 7\/89\( = \&?\)1\)

Your mission, should you decide to accept it, is to
find a permutation of the digits 1..9 on the left hand side that makes this true.

For example, one such permutation is (2/79) + (3/81) + (6/54) = 
        (370/2133) ≠ 1. 

The original problem was from the puzzle column in MIT's alumni magazine "Technology Review."
This solution was written up in the Fall of 2004, for an example in my Intro Programming with Mathematica course at Marlboro College.
Jim Mahoney (mahoney@marlboro.edu)

Definitions

Each permutation will be represented by a list, e.g. {1,2,3,4,5,6,7,8,9}.
The whole set of all permatations will be a a list of these lists, e.g. { {1,2,3,4,5,6,7,8,9}, {2,1,3,4,5,6,7,8,9}, ... }
And I'll often take a subset of a permutation, a triple like {2,3,4}.

First I'll define the functions to manipulate these data types.

\(\(\( (*\ 
      fraction[{1, 2, 3}]\ returns\ 1/
          23\ *) \)\(
\)\(\(fraction[perm3_] := 
        perm3[\([1]\)]/\((10*perm3[\([2]\)] + 
              perm3[\([3]\)])\);\)

 (*\ 
      fractionAsString[{1, 2, 
            3}]\ returns\ "1/23"\ *) 

    \(fractionAsString[perm3_] := 
        StringJoin[ToString[perm3[\([1]\)]], "/", 
          ToString[
            10*perm3[\([2]\)] + perm3[\([3]\)]]];\)

 (*\ 
      fractionSum[{1, 2, 3, 4, 5, 6, 7, 8, 9}]\ returns\ 1/23\  + \ 
        4/56\  + \ 7/89\ *) 

    \(fractionSum[perm_] := 
        fraction[Take[perm, {1, 3}]] + fraction[Take[perm, {4, 6}]] + 
          fraction[Take[perm, {7, 9}]];\)

 (*\ 
      fractionSumAsString[{1, 2, 3, 4, 5, 6, 7, 8, 
            9}]\ returns\ "1/23 + 4/56 + 7/89"\ *) 

    \(fractionSumAsString[perm_] := 
        StringJoin[
								fractionAsString[
            Take[perm, {1, 
                3}]], "+", 
								fractionAsString[
            Take[perm, {4, 
                6}]], "+", 
								fractionAsString[
            Take[perm, {7, 
                9}]]
									];\)

 (*\ 
      searchAnswer[{{1, 2, 3, 4, 5, 6, 7, 8, 9}, \ {2, 1, 3, 4, 5, 6, 7, 8, 
              9}, \  ... }]\ prints\ out\ the\ answers\ that\ work\ *) 

    \(searchAnswer[permList_] := 
        Do[
							If[\ 
            1\  == \ 
              fractionSum[
                permList[\([i]\)]], 
								Print[
              fractionSumAsString[
                permList[\([i]\)]]]
							], 
						{i, 1, 
            Length[permList]}
						];\)\)\)\)

nineDigitPermutations = 
        Permutations[Range[9]];

(* 
But if it didn' t,  
      we could define one like this .  
          The basic idea is that we define the permutation function recursively, 
      by taking each element and permuting what' 
        s left .   In other words,  
      we do something like
  perm[{1, 2, 
              3}]  =  { {1,  perm[{2, 3}]},  {2,  
              perm[{1, 3}]},  {3,  
              perm[{1, 2}]} }
However,  
      making the lists flatten out the right way is fairly tricky.
*) 
permRecur[output_, input_] := 
    If[ 
          0 == Length[input], 
 (* then *)   Flatten[
            output], 
 (* else *)  
          Table[permRecur[{output, Take[input, {n}]}, Drop[input, {n}]], {n, 
              1, Length[input]}]];

    perm[list_] := 
        Flatten[permRecur[{}, list], Length[list] - 1];

Tests

fraction[{1, 2, 3}]

FullForm[ fractionAsString[{4, 1, 2}] ]

fractionSum[Range[9]]

FullForm[ fractionSumAsString[Range[9]] ]

Length[nineDigitPermutations]

9!

perm[{1, 2, 3}]

Permutations[{1, 2, 3}]

And the answer is ... 9/12 + 5/34 + 7/68

searchAnswer[nineDigitPermutations]

This is really one one answer - the six variations are just the 3! ways to permute the three fractions.