title: Latin squares generator? (Sudoku-like constraint problem)
body: <p><strong>Purpose</strong></p>
  
  <p>We're designing a Latin square (sudoku-like sequence) for an experimental design that needs to follow these constraints:</p>
  
  <ul>
  <li>Values cannot be repeated in a row</li>
  <li>Values cannot be repeated in a column</li>
  <li>Values cannot be repeated pairwise in any two rows</li>
  </ul>
  
  <p>Example for the first 3 constraints:</p>
  
  <pre><code>2     3    5    7    11   13
  7     2    11   3    13   5
  11    5    2    13   7    3
  3     7    13   2    5    11
  5     13   3    11   2    7
  13    11   7    5    3    2 
  </code></pre>
  
  <p>Here, we chose primes, but the values are arbitrary (as long as there are 6 distinct values).  Notice that it's the same as sudoku in a 6 x 6 grid, with the additional constraint that there are no repeated pairs (a.k.a. bigrams) across rows.  That is, <code>2 3</code> only appears on the first row, but in no others, and so on for every other pair.</p>
  
  <ul>
  <li>Values should be pair with another 6 values that fit these constraints:
  
  <ul>
  <li>The 2nd-set values cannot be repeated in a row</li>
  <li>The 2nd-set values cannot be repeated in a column</li>
  <li>When paired with the 1st-set values, the 2nd-set values cannot be repeated.</li>
  </ul></li>
  </ul>
  
  <p>That is, we need to have another six values (again, arbitrary -- they could be "a, b, c, d, e, f") that pair with the first six.  The last constraint means that if you use (<code>2</code>, a) <em>anywhere</em>, you cannot use it again.</p>
  
  <p>The last 2nd-set constraint is the problem.  There is no solution for n x n grids where n = 6.  That's the monkey wrench in the works.  We want to minimize the number of repeats, to make a "sorta-kinda" orthogonal pair of Latin squares.</p>
  
  <p><strong>Question</strong></p>
  
  <p>Have you encountered this problem before?  (It'd be great if there were a tool that will generate solutions.)  We only need one such example for our purposes.  We've tried several different construction strategies already.</p>
  
  <p>We're flirting with the idea of writing a solver for it, but we'd like to avoid doing so if something already exists.</p>