How many latin-square designs are orthogonal to this 4x4 latin square design?

685 Views Asked by At

Latin Square

Where this Latin Square is similar to sudoku, in which each row has one and only one of 1,2,3 and 4, and each column has one and only one 1,2,3 and 4.

Important: orthogonality means that the new latin-square design follows the same rules but no two numbers are in the same location in both the original latin-square and new latin-square. For example 1 is in the 1,1 position in the original. Any orthogonal latin-square design will have either a 2, 3, or 4 in the 1,1 position.

I came up with 18 for answer...

1

There are 1 best solutions below

0
On

You're after the number of Latin squares which avoid the given Latin square, or equivalently the number of $4 \times 4 \times 2$ Latin cuboids with one layer given in the question. (These are necessarily not orthogonal, in the standard sense of the word.)

I'm guessing there isn't anything better than a backtracking algorithm for this problem. Here's some GAP code to do that:

AvoidMe:=[[1,2,3,4],[2,1,4,3],[3,4,1,2],[4,3,2,1]];

L:=List([1..4],i->List([1..4],j->0));
count:=0;

AddEntry:=function(i,j)
  local k;

  for k in [1..4] do

    # want to avoid this
    if(AvoidMe[i][j]=k) then continue; fi;

    # symbol already used in row
    if(ForAny([1..4],j2->L[i][j2]=k)) then continue; fi;

    # symbol already used in column
    if(ForAny([1..4],i2->L[i2][j]=k)) then continue; fi;

    L[i][j]:=k;

    if(j=4) then
      if(i=4) then
        count:=count+1;
        Print(count," ",L,"\n");
      else
        AddEntry(i+1,1);
      fi;
    else
      AddEntry(i,j+1);
    fi;

    L[i][j]:=0;
  od;
end;;

AddEntry(1,1);

and it outputs

1 [ [ 2, 1, 4, 3 ], [ 1, 2, 3, 4 ], [ 4, 3, 2, 1 ], [ 3, 4, 1, 2 ] ]
2 [ [ 2, 1, 4, 3 ], [ 1, 3, 2, 4 ], [ 4, 2, 3, 1 ], [ 3, 4, 1, 2 ] ]
3 [ [ 2, 1, 4, 3 ], [ 1, 4, 3, 2 ], [ 4, 3, 2, 1 ], [ 3, 2, 1, 4 ] ]
4 [ [ 2, 1, 4, 3 ], [ 3, 2, 1, 4 ], [ 4, 3, 2, 1 ], [ 1, 4, 3, 2 ] ]
5 [ [ 2, 1, 4, 3 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