Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>if you have N cards (N = 8), you can enumerate through all the distinct triples in the set in time N * (N - 1) * (N - 2) (with N = 8 you get 336). This is pretty fast. Check which ones of the triples are "rummy-style" sets, and store them in a table as integer triples (the integer denote the sequence numbers of the cards).</p> <p>That's the first step. The second step is now to do combinatorial optimization and calculate the optimal choice. The simple way to do this is to use backtracking search. You run an index ('i') over the set of triples you have found. First you try to include the 'i'th triple in the solution, and then continue from index i+1 recursively; then you backtrack and decide that the 'i'th triple is <em>not</em> in the solution, and continue from i+1 recursively. There are many optimizations to this, but for the small sets it's going to work pretty fine.</p> <p>Here how it works with your example:</p> <p>Cards: 6D, 7D, 7C, 7H, 8D, 8C, 9C, 10H</p> <p>Let's enumerate all the possible triples:</p> <pre><code>Cards Index triple 6D 7D 8D &lt;0, 1, 4&gt; 7D 7C 7H &lt;1, 2, 3&gt; 7C 8C 9C &lt;2, 5, 6&gt; </code></pre> <p>The full backtracking search goes like this:</p> <pre><code>Decide on &lt;0, 1, 4&gt;: &lt;0, 1, 4&gt; INCLUDED: &lt;1, 2, 3&gt; CLASHES with &lt;0, 1, 4&gt; Decide on &lt;2, 5, 6&gt;: &lt;2, 5, 6&gt; INCLUDED: Solution with 2 sets (* BEST SOLUTION) &lt;2, 5, 6&gt; EXCLUDED: Solution with 1 sets &lt;0, 1, 4&gt; EXCLUDED: Decide on &lt;1, 2, 3&gt;: &lt;1, 2, 3&gt; INCLUDED: &lt;2, 5, 6&gt; CLASHES with &lt;1, 2, 3&gt; Solution with 1 sets &lt;1, 2, 3&gt; EXCLUDED: Decide on &lt;2, 5, 6&gt;: &lt;2, 5, 6&gt; INCLUDED: Solution with 1 set &lt;2, 5, 6&gt; EXCLUDED: Solution with 0 sets </code></pre> <p>Then you pick the solution with most sets (marked with asterisk).</p> <p>This is pretty simple to implement. Try it!</p>
 

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