18
2
Challenge
Write a program or a function that returns or prints a square-random-symmetrical matrix.
Input
N: The size of the matrix i.e 6 x 6
Output
The matrix. You can either print it, return it as string (with the newlines) or as a list/array of lists/arrays.
Rules
You need to use at least
N
different characters, whereN
is the size of the square matrix (input). Since we 're using only letter [a, z][A, Z] and digits [0, 9] (and only 1 digit at the time) you can assume thatN < 27
andN > 2
, that is because atN <= 2
you can't have both letters and digits. Last but not least, every letter/digit must have non-zero probability of occurring (uniform distribution is not a necessity). However, the result must have at leastN
different letter/digits.The matrix has to be both horizontally and vertically symmetrical.
Exactly 2 rows and 2 columns must contain strictly one single-digit number (it's position should be random as well). The rest of rows/cols will contain only letters. Consider letters as [a, z] and [A, Z] and of course single-digit numbers as [0, 9].
Just to be easier, you can assume that the case of the letters doesn't matter, as long as the cases are symmetrical which means:
a=A, b=B, etc
.Every possible output must have a non-zero probability of occurring. The random distribution doesn't need to be uniform.
Example
Input: 8
Output:
c r p s s p r c
r k o z z o k r
u t 2 a a 2 t u
y n q z z q n y
y n q z z q n y
u t 2 a a 2 t u
r k o z z o k r
c r p s s p r c
Comments are not for extended discussion; this conversation has been moved to chat.
– Mego – 2018-08-31T02:30:04.467