title: Algorithm to find an optimum number of rummy-style sets?
body: <p>I'm developing a card game that uses rummy-style sets of three cards.  From a random selection of cards, I need the algorithm to pick out which cards would get me the highest number of sets.</p>
  
  <p>By "rummy-style sets of three" I mean:</p>
  
  <ul><li>All three cards have the same value, like three Jacks. OR</li>
  <li>All three cards are of the same suit and sequential in order, like a 7, 8, 9 all of diamonds.</li></ul>
  
  <p>For example, given the cards: 6D, 7D, 7C, 7H, 8D, 8C, 9C, 10H<br/>
  I could form the set: {7D, 7C, 7H}, but that would be the only set I would get out of it, and it would not be optimum.<br/>
  The optimum sets in this case are: { {6D, 7D, 8D}, {7C, 8C, 9C} }</p>
  
  <p>I have tried brute force (permute through all the given cards, see what matches in order in that permutation), but that proved too slow.  The problem feels like it has similarities to other solved problems, and that's why I ask here.</p>