Latin Squares
June 18, 2019
A latin square of order n is a square matrix with n rows and n columns, with each entry in the matrix containing an integer from 0 to n − 1, arranged so that no row or column contains duplicate integers. Here is a sample latin square of order 10:
8 3 7 1 5 6 4 2 0 9 4 5 6 2 0 9 3 7 8 1 9 2 3 8 7 5 1 4 6 0 2 6 0 3 9 8 7 5 1 4 0 4 2 9 3 7 8 1 5 6 6 1 4 0 2 3 9 8 7 5 1 7 5 4 6 0 2 3 9 8 3 0 9 7 8 1 5 6 4 2 5 8 1 6 4 2 0 9 3 7 7 9 8 5 1 4 6 0 2 3
Your task is to write a program that generates latin squares of order n. When you are finished, you are welcome to read or run a suggested solution, or to post your own solution or discuss the exercise in the comments below.