Friday, November 11, 2016

Latin Square - GeeksforGeeks

Latin Square - GeeksforGeeks
A Latin Square is a n x n grid filled by n distinct numbers each appearing exactly once in each row and column. Given an input n, we have to print a n x n matrix consisting of numbers from 1 to n each appearing exactly once in each row and each column.

In the first row, the numbers are stored from 1 to n serially.

the second row, the numbers are shifted to the right by one column. i.e, 1 is stored at 2nd column now and so on.

In the third row, the numbers are shifted to the right by two columns. i.e, 1 is stored at 3rd column now and so on.