A Latin square of size n is an arrangement of n symbols in an n-by-n square in such a way that each row and column has each symbol appearing exactly once.

A randomised Latin square generates random configurations of the symbols for any given n.

Example n=4 randomised Latin square

0 2 3 1
2 1 0 3
3 0 1 2
1 3 2 0
Task

 Create a function/routine/procedure/method/... that given n generates a randomised Latin square of size n.
 Use the function to generate and show here, two randomly generated squares of size 5.
Note
 
Strict Uniformity in the random generation is a hard problem and not a requirement of the task.

Reference

 Wikipedia: Latin square
 OEIS: A002860


main =>
  _ = random2(), % random seed
  N = 5,
  foreach(_ in 1..2)
    latin_square(N, X),
    pretty_print(X)
  end,
  % A larger random instance
  latin_square(62,X),
  pretty_print(X).
 
% Latin square
latin_square(N, X) =>
  X = new_array(N,N),
  X :: 1..N,
  foreach(I in 1..N)
    all_different([X[I,J] : J in 1..N]),
    all_different([X[J,I] : J in 1..N])
  end,
  % rand_val for randomness
  solve($[ff,rand_val],X).
 
pretty_print(X) =>
  N = X.len,
  Alpha = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
  foreach(I in 1..N)
    foreach(J in 1..N)
      if N > 20 then
        printf("%w",Alpha[X[I,J]])
      else
        printf("%2w ",X[I,J])      
      end
    end,
    nl
  end,
  nl.