Given 3 columns and 3 iterations. Variants of placement of one number so that it would be possible to determine the number by placement - nine: 000 (the number is always in place), 001, 002, 010, 011, 012, 020, 021, 022.
We take 9 numbers for each column. We can fill an array of 27 elements with random, unique numbers. Further, in the description of the algorithm, by number we mean its position in this array, starting from 0. The columns "on the screen" will be numbered 0, 1, 2. At the first iteration, the first 9 numbers are entered in the 0 column , the second in the 1st, the third in the 2nd . When placed on the second iteration, we take the remainder before dividing the number by 9 (in fact, this is the number of the number in its group of the first iteration). We divide this remainder completely by 3 — this is how many columns you need to shift the number at the second iteration relative to the initial position ( смещение = (X % 9) / 3 ). If the number of the original column + offset is greater than 2, then we start the counting from the beginning (ie, do 2-(K1+смещение) ) At the third iteration, take the remainder of the division by 3 ( смещение=X % 3 ). With this approach, for each number we get the arrangements indicated at the very beginning of the post.
Guessing: Multiply the column number of the first iteration by 9, add the column number of the second iteration multiplied by 3, add the column number of the third iteration ( K1*9+K2*3+K3 ). All, got a number (well, that is, its position in the initial array).
Example:
1я итерация 2я итерация 3я итерация 0 1 2 0 1 2 0 1 2 0 9 18 0 3 6 0 1 2 1 10 19 1 4 7 3 4 5 2 11 20 2 5 8 6 7 8 3 12 21 9 12 15 9 10 11 4 13 22 10 13 16 12 13 14 5 14 23 11 14 17 15 16 17 6 15 24 18 21 24 18 19 20 7 16 25 19 22 25 21 22 23 8 17 26 20 23 26 24 25 26
User entered: 2nd, 1st, 0th: 2*9+1*3+0=21 , entered 1st, 2nd, 1st: 1*9+2*3+1=16
The contents of the columns at each iteration can be mixed, so that no regularities in the distribution can be seen.
Direct printing of indices of the original array on php (formulas are revised for the case of printing all three iterations into a string, as in the example above):
for($i=0;$i<9;$i++) { // Строка for($j=0;$j<3;$j++) { // Итерация for($k=0;$k<3;$k++) { // Колонка if($j==0) $m=$i+9*$k; elseif($j==1) $m=(int)($i/3)*9+$i%3+$k*3; else $m=$i*3+$k; printf("%3d",$m); } print " "; } print "\n"; }