Beispiel #1
0
 public void Mark(DLX solver)
 {
     solver.Mark(C1).Mark(C2 + 65);
 }
Beispiel #2
0
            public void Mark(DLX solver)
            {
                // mark the cell as being used
                solver.Mark((0 * 5 * 81) + (Board * 81) + (Block * 9) + (3 * R) + C);

                // mark the column as containing n
                solver.Mark((1 * 5 * 81) + Board * 81 + 27 * (Block % 3) + 9 * C + N);

                // mark the row as containing n
                solver.Mark((2 * 5 * 81) + Board * 81 + 27 * (Block / 3) + 9 * R + N);

                // mark the block as containing n
                solver.Mark((3 * 5 * 81) + 9 * (Board * 9 + Block) + N);

                if ((Board == 0 && Block == 8) || (Board == 1 && Block == 6) || (Board == 3 && Block == 2) || (Board == 4 && Block == 0)) {
                    // also mark the middle board

                    int MiddleBlock = 8 - Block;
                    int MiddleBoard = 2;

                    // mark the column as containing n
                    solver.Mark((1 * 5 * 81) + MiddleBoard * 81 + 27 * (MiddleBlock % 3) + 9 * C + N);

                    // mark the row as containing n
                    solver.Mark((2 * 5 * 81) + MiddleBoard * 81 + 27 * (MiddleBlock / 3) + 9 * R + N);
                }
            }
Beispiel #3
0
            public void Mark(DLX solver)
            {
                // add a row for this number in this row and column
                int block = (R / 3) + 3 * (C / 3); // relying on truncation, of course

                // mark the cell as being used
                solver.Mark(0 * 81 + 9 * R + C);

                // mark the column as containing n
                solver.Mark(1 * 81 + 9 * C + N);

                // mark the row as containing n
                solver.Mark(2 * 81 + 9 * R + N);

                // mark the block as containing n
                solver.Mark(3 * 81 + 9 * block + N);
            }