I want to construct a random square matrix in the following manner:

![enter image description here](https://i.stack.imgur.com/IJZ4f.jpg)

a) Three states `[0 | 1 | 2]` are repeated `[2 | 4 | 6 | 8 | 10]` times in each row

b) All numbers of current row must be different from the numbers directly above them

I have written:

Make one row

```
mrow := Module[{x},
  Take[
   Flatten @ Table[x = RandomInteger[{0, 2}];
     Table[x, {RandomChoice[{2, 4, 6, 8}]}], {5}],
   10]]

```

Prepare matrix with indexed variable `row`. Determine by subtraction whether next row is different. If not `While` - loop until a different row is found.

```
For[n = 2; row[1] = mrow, n <= 10, n++,
 row[n] = mrow;
 While[MemberQ[row[n - 1] - row[n], 0], row[n] = mrow]];

```

Output matrix

```
Map[row[#] &, Range[10]] // MatrixPlot

```

![enter image description here](https://i.stack.imgur.com/mvvLD.jpg)

Unfortunately, for the first time, I had to use `For` and `While` with MMA programming.

Do you see any functional way to get the desired result?