ROSECODE 567
Shuffling Cards revisited
A standard deck of 52 playing cards, which consists of thirteen ranks (Ace, Two, ..., Ten, King, Queen and Jack) each in four suits (Clubs, Diamonds, Hearts and Spades), is randomly shuffled. A connection is defined as two cards with the same rank appearing next to each other. Let us call a rank perfect-k if
For examples, the following card arrangement has one perfect-0, one perfect-1, and one perfect-2(where S=spade, H=Heart, D=diamond, and C=club).
[7D][5C][7C][2S][7H][2D][2H][7S][2C][5D][5S][5H]
Rank 2 is perfect-1 because there is only one connection between 2D and 2H, Rank 5 is perfect-2 because one connection occurs between 5D and 5S, another connection occurs between 5S and 5H. Rank 7 is perfect-0 since no connections occur.
Let
You are given
Find