Forum Discussion

anupambit1797's avatar
anupambit1797
Iron Contributor
May 16, 2023
Solved

How to create a Latin Square in Excel

Dear Experts,

                   Could you please help explain on how can we create a Latin-Square in Excel?

An n x n Latin Square is a Latin square consists of sets of the numbers 1 to n arranged in such a way that no orthogonal (row or column) contains the same number twice. Example ,the 12 Latin squares of order three are given by :-

 

 

Thanks in Advance,

Br,

Anupam

1 Reply

  • Patrick2788's avatar
    Patrick2788
    Silver Contributor

    anupambit1797 

     

    Here's my solution. I've attached a sample workbook.

     

    'LatinSquare
    =LAMBDA(n,MAKEARRAY(
        n,
        n,
        LAMBDA(r, c,
            LET(
                seq, SEQUENCE(, n),
                arr, HSTACK(TAKE(seq, , -(r - 1)), TAKE(seq, , n - (r - 1))),
                IF(r = 1, c, INDEX(arr, , c))
            )
        )
    ))

     

     

Resources