IsLatinSquare( M )
IsLatinSquare
determines if a matrix M is a latin square. For a latin
square of size n by n, each row and each column contains all the
integers 1..n exactly once.
gap> IsLatinSquare([[1,2],[2,1]]); true gap> IsLatinSquare([[1,2,3],[2,3,1],[1,3,2]]); false
GAP 3.4.4