Counting the Diamonds Behind Closed Hands
The dummy comes down, and our two hands contain eight diamonds. Five are still hiding across the table. Before committing to a line of declarer play, I want to know how often those missing diamonds divide three–two between the defenders.
Bridge players learn to count cards. Computers offer a useful extension: count the possible hiding places before any cards have been played.
Imagine the defenders’ hands as 26 labelled slots, 13 apiece. Choosing five slots for the missing diamonds gives C(26, 5) possibilities. For a three–two split, choose three slots in one hand and two in the other. Either defender can hold the three, so double that count.
Ruby makes a small counting tool:
def choose(n, k)
count = 1
1.upto(k) do |i|
count = count * (n - i + 1) / i
end
count
end
favourable = 2 * choose(13, 3) * choose(13, 2)
total = choose(26, 5)
printf "Three-two split: %.2f%%\n", 100.0 * favourable / total
The result is Three-two split: 67.83%. No shuffled decks, no repeated trials: we counted every relevant arrangement without constructing a single hand.
The same arithmetic fits comfortably into C:
#include <stdio.h>
long choose(int n, int k) {
long count = 1;
for (int i = 1; i <= k; ++i)
count = count * (n - i + 1) / i;
return count;
}
int main(void) {
long favourable = 2 * choose(13, 3) * choose(13, 2);
long total = choose(26, 5);
printf("Three-two split: %.2f%%\n", 100.0 * favourable / total);
return 0;
}
Each loop builds a binomial coefficient using exact integer arithmetic; floating point enters only when displaying the percentage. C’s long easily handles this example, though larger counting problems can overflow it. Ruby’s integers grow as needed.
There is a catch at the card table: this calculation assumes every placement is equally likely, with no information from bidding or play. A revealing auction changes the question. So does a defender showing out of another suit.
That is what I like about this little program. It gives intuition a precise starting point, while leaving the interesting bridge judgement firmly in our hands.