rand7() and store the result in row, giving us a number from 1 to 7.rand7() again and store the result in col, giving us another number from 1 to 7.idx = (row - 1) * 7 + col, which gives us a number from 1 to 49.idx is less than or equal to 40, return idx % 10 + 1 to get a number from 1 to 10.idx is greater than 40, reject it and go back to step 1.