Given positive integer
n < 10, create a 2 dimensional matrix where each location is filled with its
y index (starting from the top left).
00 10 10 11
00 10 20 01 11 21 02 12 22
Once the grid is created, randomly fill each index. This can be with an 'x' or any other way to denote a spot has been filled.
You determine which location to fill by randomly generating indices to fill the matrix. You can only fill n^2 times so you cannot fill as many times as you want until the matrix is completely filled. At the end the matrix must be filled so you must do some work to make sure that you check the random numbers that you use to fill to make sure that spot is not already filled.
Refresh or print after each fill in order to show the progression of the filling iterations.
Example for filling:
00 10 01 11
00 is randomly chosen:
XX 10 01 11
01 is randomly chosen:
XX 10 XX 11
00 is randomly chosen, but since it's already been chosen a re-roll chooses
XX XX XX 11
11 is randomly chosen:
XX XX XX XX
Do not print out the random numbers as visually I should be able to see which index was selected. By this I mean do not print "
11 is randomly chosen:". It is here for exploratory sake.
Since this is code-golf The shortest code wins.
Have fun and happy golfing!