                    ABCD
                    CABD
                    ACDB
                    DACB
                    BCDA
                    ACBD
                    ADCB
                    CDAB
                    DABC
                    BCAD
                    CADB
                    CDBA
                    CBAD
                    ABDC
                    ADBC
                    BDCA
                    DCBA
                    BACD
                    BADC
                    BDAC
                    CBDA
                    DBCA
                    DCAB

Listed above are   all-but-one   of the permutations of the symbols   A,   B,   C,   and   D,   except   for one permutation that's   not   listed.



Task

Find that missing permutation.



Methods

 Obvious method: 
        enumerate all permutations of   A,  B,  C,  and  D,  
        and then look for the missing permutation. 

 alternate method:
        Hint:  if all permutations were shown above,  how many 
        times would  A  appear in each position?     
        What is the  parity  of this number?

 another alternate method:
        Hint:  if you add up the letter values of each column, 
        does a missing letter   A,  B,  C,  and  D   from each
        column cause the total value for each column to be unique?



Related task

   Permutations)


$ include "seed7_05.s7i";
 
const func string: missingPermutation (in array string: perms) is func
  result
    var string: missing is "";
  local
    var integer: pos is 0;
    var set of char: chSet is (set of char).EMPTY_SET;
    var string: permutation is "";
    var char: ch is ' ';
  begin
    if length(perms) <> 0 then
      for key pos range perms[1] do
        chSet := (set of char).EMPTY_SET;
        for permutation range perms do
          ch := permutation[pos];
          if ch in chSet then
            excl(chSet, ch);
          else
            incl(chSet, ch);
          end if;
        end for;
        missing &:= min(chSet);
      end for;
    end if;
  end func;
 
const proc: main is func
  begin
    writeln(missingPermutation([] ("ABCD", "CABD", "ACDB", "DACB", "BCDA", "ACBD",
           "ADCB", "CDAB", "DABC", "BCAD", "CADB", "CDBA", "CBAD", "ABDC", "ADBC",
           "BDCA", "DCBA", "BACD", "BADC", "BDAC", "CBDA", "DBCA", "DCAB")));
  end func;