Random Latin squares: Difference between revisions

Line 1,681:
14 1 9 6 10 5 11 3 16 2 4 13 12 15 8 7
</pre >
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<lang Mathematica>Clear[RandomLatinSquare]
RandomLatinSquare[n_] := Module[{out, ord},
out = Table[RotateLeft[Range[n], i], {i, n}];
ord = RandomSample[Range[n]];
out = out[[ord]];
ord = RandomSample[Range[n]];
out = out[[All, ord]];
out
]
RandomLatinSquare[5] // Grid</lang>
{{out}}
<pre>5 2 4 1 3
2 4 1 3 5
4 1 3 5 2
3 5 2 4 1
1 3 5 2 4</pre>
 
=={{header|Nim}}==
1,111

edits