program F_Tables;
var
Permutations:integer;
{ ------------------------------------------------------------ }
function AnsIsLegal(S:string):boolean;
var
aCOunt,
bCOunt,
cCOunt:integer;
i:integer;
begin
aCount := 0;
bCount := 0;
cCount := 0;
for i := 1 to 5 do
begin
case S of
'A': inc(aCOunt);
'B': inc(bCOunt);
'C': inc(cCOunt);
end;
end;
result := true;
if aCOunt <> 2 then
result := false;
if bCOunt <> 2 then
result := false;
if cCOunt <> 1 then
result := false;
end;
{ ------------------------------------------------------------ }
procedure AddToLIst(S:string);
var
i:integer;
begin
if AnsIsLegal(S) then
begin
for i := 1 to 5 do
case S of
'A': write('12 ');
'B': write('11 ');
'C': write('10 ');
end; { case }
writeln('');
inc(Permutations);
end;
end;
{ ------------------------------------------------------------ }
procedure FindAll;
var
Ac,Bc,Cc,Dc,Ec:Char;
S:string;
begin
Permutations := 0;
For Ac := 'A' to 'C' do
For Bc := 'A' to 'C' do
For Cc := 'A' to 'C' do
For Dc := 'A' to 'C' do
For Ec := 'A' to 'C' do
begin
S := Ac + Bc + Cc + Dc + Ec;
AddToList(S);
end;
writeln(Permutations,' Permutations found');
writeln('press return to exit');
readln(S); // in case running in dos window then keep window open
end;
{ ------------------------------------------------------------ }
begin { F_Tables }
FindAll;
end.
John Pears, Coventry, England.