Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Consider the following grid:</p> <pre><code> 1 2 3 4 | 5 6 7 8 | 9 10 11 12 | 13 14 15 16 5 6 7 8 | 9 10 11 12 | 13 14 15 16 | 1 2 3 4 9 10 11 12 | 13 14 15 16 | 1 2 3 4 | 5 6 7 8 13 14 15 16 | 1 2 3 4 | 5 6 7 8 | 9 10 11 12 ------------+-------------+-------------+------------ 2 3 4 1 | 6 7 8 5 | 10 11 12 9 | 14 15 16 13 6 7 8 5 | 10 11 12 9 | 14 15 16 13 | 2 3 4 1 10 11 12 9 | 14 15 16 13 | 2 3 4 1 | 6 7 8 5 14 15 16 13 | 2 3 4 1 | 6 7 8 5 | 10 11 12 9 ------------+-------------+-------------+------------ 3 4 1 2 | 7 8 5 6 | 11 12 9 10 | 15 16 13 14 7 8 5 6 | 11 12 9 10 | 15 16 13 14 | 3 4 1 2 11 12 9 10 | 15 16 13 14 | 3 4 1 2 | 7 8 5 6 15 16 13 14 | 3 4 1 2 | 7 8 5 6 | 11 12 9 10 ------------+-------------+-------------+------------ 4 1 2 3 | 8 5 6 7 | 12 9 10 11 | 16 13 14 15 8 5 6 7 | 12 9 10 11 | 16 13 14 15 | 4 1 2 3 12 9 10 11 | 16 13 14 15 | 4 1 2 3 | 8 5 6 7 16 13 14 15 | 4 1 2 3 | 8 5 6 7 | 12 9 10 11 </code></pre> <p>Assuming that I haven't made any typos, it should be obvious (from the pattern of its construction) that this follows the requirements of a Sudoku layout (each value 1..16 occurs exactly once in each row, column, and 4x4 subgrid).</p> <p>In addition, it should be obvious that each of the following changes leaves the requirements satisfied (where 1-origin indexing is assumed):</p> <ol> <li><p><em>Column swaps</em>: exchange the entire contents of any two columns that lie within the same subgrid (e.g. swapping cols 1 and 3, swapping cols 10 and 11, but <strong>not</strong> swapping cols 6 and 13).</p></li> <li><p><em>Row swaps</em>: exchange the entire contents of any two columns that lie within the same subgrid (similar indexing to #1).</p></li> <li><p><em>Subgrid column swaps</em>: exchange corresponding columns of two columns of subgrids (e.g. swap subgrid cols 2 and 4, which means swapping all of cols 5 and 13, cols 6 and 14, cols 7 and 15, and cols 8 and 16).</p></li> <li><p><em>Subgrid row swaps</em>: exchange corresponding rows of two rows of subgrids (similar indexing to #3).</p></li> </ol> <p>So, based on the above facts, the strategy is to begin with the grid shown above, then for some suitable number of iterations (you can determine this by experiment), randomly choose one of the four transforms, and apply it to randomly-chosen indices that satisfy the requirements stated for the transform.</p> <blockquote> <p>For example, to apply transform #1, randomly choose a subgrid column number <code>sgcn</code> in the range (1..4), then randomly choose two distinct column numbers <code>cn1</code> and <code>cn2</code> in the range (1..4). Swap all values in columns <code>(sgcn - 1) * 4 + cn1</code> and <code>(sgcn - 1) * 4 + cn2</code>.</p> </blockquote> <p>By starting with a (any) legal grid, and performing legality-preserving transformations, the result is guaranteed to be legal. However, as the number of transforms applied increases, it is progressively more difficult for a human observer to distinguish the pattern from randomness.</p> <p>Replacing values in the "scrambled" grid with blanks to get the desired degree of difficulty.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload