If I wanted the different 3-card possible combinations from a total of 4 cards in ascending order, I would have:






How can I get all the possible, unique triplets in ascending order given an arbitrarily selected subset of cards from a standard deck of 52 cards?

I was misunderstanding the problem. Here's a bigger example, I'm given the cards:

$6, 1, 4, 3, 2, 4, 5$

  • I can have more than one card with the same number, but each triplet cannot contain repeated numbers.
  • Each triplet has to be in ascending order, but within the constraints of the original order.

In this example, the number 6 cannot appear in any triplet. The first 4 isn't going to appear in any triplet either, but the second 4 allows to form (1,4,5). The results are:






With these restrictions in place, it's probably not a combinatorics problem.

  • $\begingroup$ Do you mean the standard deck of $52$ cards (which is the usual context) or do you mean cards numbered from $1$ to $52$ (which your example seems to suggest)? $\endgroup$ – Cameron Buie Jun 24 '13 at 4:31
  • 1
    $\begingroup$ Counting is straightforward, it is $\binom{52}{3}$. As to an explicit list, "alphabetical order" sounds good. $\endgroup$ – André Nicolas Jun 24 '13 at 4:38
  • $\begingroup$ Cameron, sorry about that, I meant 52 cards numbered from 1 to 52, will edit now. $\endgroup$ – sker Jun 24 '13 at 14:32
  • $\begingroup$ Turns out, it is a standard deck of 52 cards. $\endgroup$ – sker Jun 24 '13 at 16:55

Hint: for any triplet there are $6$ orders and you accept $1$. Do you want the number of them or a list. The list will be too large for most purposes.

  • $\begingroup$ I want the number of them only. In this example something like 4C'3 -> 4. Where C' stands for alphabetical order. $\endgroup$ – sker Jun 24 '13 at 14:35
  • $\begingroup$ @sker: For $n$ cards it is ${n \choose 3}$ because you once you select them, you can put them in exactly one order. $\endgroup$ – Ross Millikan Jun 24 '13 at 15:27
  • $\begingroup$ You're right, I had misunderstood the problem. I just updated the question. Any ideas? $\endgroup$ – sker Jun 24 '13 at 16:55
  • $\begingroup$ With the edit, the deck is an existing sequence and you are looking for the number on increasing subsequences. There is no simple formula-$1$ to $52$ in order has ${52 \choose 3}$ subsequences, while if it starts in reverse order there are none. I think all you can do is count: start with the first element, look through the list for higher values to the right, then look for acceptable third values. Keep looping. $\endgroup$ – Ross Millikan Jun 24 '13 at 17:11
  • $\begingroup$ Yes, I suppose I have to code one of those search algorithms to get the right answer. Thanks for your help. $\endgroup$ – sker Jun 24 '13 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.