Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

How many arrangements (permutations) of a set of $\frac{n(n+1)}{2}$ distinct cards, each having one of $n$ colors $c_1,\ldots,c_n$ where there are $i$ cards of color $c_i$ that are numbered $1,2,\ldots,i$, satisfy the following constraint: any two cards of the same color and with consecutive numbers cannot be adjacent in the arrangement. This seems to be similar to this problem, but in our case all the cards are distinct, whereas in that problem the cards of the same color are all identical.

share|improve this question
How many cards are in an arrangement? Can you give an example of a forbidden arrangement? –  Phira Apr 9 '12 at 8:48
Do you want permutations of the entire deck in which no two adjacent cards of consecutive numbers of the same color? –  Brian M. Scott Apr 9 '12 at 9:01
Yes, it is exactly what I mean. For example, case $n=3$, red 1, blue 1, 2 and green 1, 2, 3. Blue1 should not be adjacent to Blue2. Neither Green1 and Green2, nor Green2 and Green3. –  hkju Apr 9 '12 at 9:09
Please, fix the question, so that it actually expresses what you mean. Then, please tell us where this question comes from and what kind of answer you expect. –  Phira Apr 9 '12 at 9:24
@Marc: I count $1,2,216,954432$ for the first four terms (here's the code). That sequence isn't in OEIS. –  joriki Apr 10 '12 at 8:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.