8
$\begingroup$

Can any $9\times 9$ - Latin Square be transformed into a sudoku by just exchanging rows and columns (it is allowed to mix row- and column-exchanges arbitarily and there is no limit for the number of the exchanges) ?

$\endgroup$
  • 3
    $\begingroup$ Seems unlikely, but don't have a counter-example just yet. $\endgroup$ – Thomas Andrews Jul 22 '14 at 16:27
  • $\begingroup$ I agree with this intuition, but perhaps there is a surprise waiting for me. $\endgroup$ – Peter Jul 22 '14 at 16:31
  • $\begingroup$ I think that in the simpler case of $4\times4$ the answer is affirmative. Unless I made a mistake all we need to do to a given latin square is to select row number two with a modicum of care. Yet, I would be somewhat surprised if the same held for all $9\times9$ latin squares, but I don't have a strong intuition about it. $\endgroup$ – Jyrki Lahtonen Jul 22 '14 at 16:43
  • $\begingroup$ Switching rows and permuting columns commutes, by the way. $\endgroup$ – Thomas Andrews Jul 22 '14 at 16:49
  • 2
    $\begingroup$ if you can look up the total number of Latin squares of size 9, divide by $(9!)^2,$ and compare with the (known) number of complete sudokus, you may get an easy negative answer that way. $\endgroup$ – Will Jagy Jul 22 '14 at 17:21
4
$\begingroup$

No, this one can't:

$$ L= \begin{bmatrix} 8 & 9 & 5 & 4 & 7 & 3 & 6 & 2 & 1 \\ 4 & 3 & 2 & 6 & 9 & 8 & 5 & 1 & 7 \\ 1 & 5 & 3 & 8 & 4 & 2 & 9 & 7 & 6 \\ 3 & 1 & 7 & 9 & 5 & 6 & 4 & 8 & 2 \\ 6 & 2 & 4 & 5 & 3 & 1 & 7 & 9 & 8 \\ 5 & 7 & 1 & 3 & 2 & 4 & 8 & 6 & 9 \\ 9 & 6 & 8 & 2 & 1 & 7 & 3 & 4 & 5 \\ 7 & 8 & 9 & 1 & 6 & 5 & 2 & 3 & 4 \\ 2 & 4 & 6 & 7 & 8 & 9 & 1 & 5 & 3 \\ \end{bmatrix} . $$

Will Jagy's answer implies that if we generate a random Latin square of order $9$, it will very likely not be equivalent to a sudoku by permuting the rows and columns. So I generated a random Latin square $L$ (above) of order $9$, with rows/columns/symbols in $\{1,2,\ldots,9\}$.

We can permute the rows and columns in $9!^2$ ways. However, if we permute e.g. only the first three rows, we preserve sudoku-ness (and non-sudoku-ness). The same thing if we permute the second three rows (i.e., rows $\{4,5,6\}$), the first three columns, and so on.

Let $$G=\langle (1,2),(1,2,3),(4,5),(4,5,6),(7,8),(7,8,9)\rangle \leq S_9.$$ Then $G$ acts on $S_9$ by composition. There are $|S_9|/|G|=9!/(3!)^3=1680$ orbits under this action, so it is sufficient to check $(1680)^2=2822400$ row-column permutation pairs to verify that $L$ cannot be transformed into a sudoku by permuting the rows and columns. I did this on the computer using GAP:

L:=
[ [ 8, 9, 5, 4, 7, 3, 6, 2, 1 ], 
  [ 4, 3, 2, 6, 9, 8, 5, 1, 7 ], 
  [ 1, 5, 3, 8, 4, 2, 9, 7, 6 ], 
  [ 3, 1, 7, 9, 5, 6, 4, 8, 2 ], 
  [ 6, 2, 4, 5, 3, 1, 7, 9, 8 ], 
  [ 5, 7, 1, 3, 2, 4, 8, 6, 9 ], 
  [ 9, 6, 8, 2, 1, 7, 3, 4, 5 ], 
  [ 7, 8, 9, 1, 6, 5, 2, 3, 4 ], 
  [ 2, 4, 6, 7, 8, 9, 1, 5, 3 ] ];

G:=Group((1,2),(1,2,3),(4,5),(4,5,6),(7,8),(7,8,9));;
Orbs:=Orbits(G,SymmetricGroup(9),OnRight);;
Reps:=List(Orbs,O->O[1]);;

PermuteRowsMatrix:=function(L,perm)
  return List([1..Size(L)],i->L[i^Inverse(perm)]);
end;;

PermuteColumnsMatrix:=function(L,perm)
  return List([1..Size(L)],i->List([1..Size(L[1])],j->L[i][j^Inverse(perm)]));
end;;

IsSudoku:=function(M)
  local r,c,i,j,S;
  for r in [1..3] do
    for c in [1..3] do
      S:=[];
      for i in [1..3] do
        for j in [1..3] do
          Append(S,[M[3*(r-1)+i][3*(c-1)+j]]);
        od;
      od;
      if(Set(S)<>[1..9]) then return false; fi;
    od;
  od;
  return true;
end;;

for alpha in Reps do
  for beta in Reps do
    M:=PermuteRowsMatrix(PermuteColumnsMatrix(L,beta),alpha);
    if(IsSudoku(M)) then
      Print("This Latin square can be transformed into the following Sudoku square by row/column permutations:\n",M,"\n");
    fi;
  od;
od;
$\endgroup$
3
$\begingroup$

says 5,524,751,496,156,892,842,531,225,600 nine by nine latin squares, then 6,670,903,752,021,072,936,960 sudoku, ratio about one million. Meanwhile $9! = 362,880$ and $(9!)^2 \approx 1.3168 \cdot 10^{11},$ much bigger than a million. So, we cannot rule anything out by simple counting; perhaps more complicated counting...

Note: might be worth considering the rectangular types, for example you can make a 6 by 6 puzzle out of six 2 by 3 rectangles, each of which is required to hold the numbers 1 through 6. On that note, any $n$ by $n$ sudoku made up of (parallel) 1 by $n$ rectangles is just a Latin square, no transformation required. This suggests that rectangular type puzzles get more restrictive as the sub-blocks get closer to square.

$\endgroup$
1
$\begingroup$

Not an answer, but too complicated for a comment.

A $9\times 9$ latin square is a map $S:N\times N\to N$ with certain properties, where $N=\{1,2,\dots,9\}$.

$S$ can be made a Sudoku by permuting columns and rows if and only if there are two partitions $$N=U_1\cup U_2\cup U_3 = V_1\cup V_2\cup V_3$$ such that $S(U_i\times V_j)=N$ for all $i,j$.

(If $S$ was already in Sudoku form, then $U_1=V_1=\{1,2,3\}$, $U_2=V_2=\{4,5,6\}$, and $U_3=V_3=\{7,8,9\}$.)

$\endgroup$
1
$\begingroup$

Elaborating on my thinking in the 4x4 case, so not an answer.

The latin condition takes care of the rows and columns. We need to show that shuffling of rows (turns out that there is no need to shuffle columns) allows us to have all four numbers appear in the 2x2 blocks.

Start with a 4x4 latin square. Without loss of generality (shuffle the numbers) we can assume that the 1st row is 1234. Let us look at the first two columns. In addition to having a 1 and a 2 on the first row there is exactly one more 1 and one more 2 on some other rows. Therefore there is at least one row such that neither 1 nor 2 appears on the two first columns. In other words at least one of the other rows has a 3 and a 4 (in some order) as the two first entries.

Let us interchange rows of the latin square minimally in such a way that a row beginning with 34 (or 43) becoms the second row. A single swap is enough to achieve this. At this point the top left 2x2 block has been taken care of. But the latin property then implies that the four entries in the top right and bottom left 2x2 blocks are all distinct. Repeating the dose shows that the same holds for the bottom right 2x2 block.

Permuting rows won't change the latin property, so the sudoku rules on rows/columns are still observed.

$\endgroup$
  • 1
    $\begingroup$ And similarly for the 9x9 case it should suffice to fix the top-left 6x6 block. $\endgroup$ – Peter Taylor Jul 23 '14 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.