I'm sure this is a known problem but it defies a Google search! I'm interested in the number of unique Tic-Tac-Toe boards in which all 9 squares are filled, even if they result in non-sensical games where both sides win. So the question is: With five white stones (O) and four black stones (X), how many distinct arrangements are there, given that all same-colored stones look exactly alike?
I'd be happy just to know what this variety of combinatorics is called, since it's something between a combination and a permutation. But I've worked out a bit of it:
Of course, we know there are 9!
routes to the final state, but many will be identical in the end since the order in which the stones were placed is not evident in the final product.
Likewise, if we think of a given board as a nine-digit binary number, which 1
s as Os and 0
s as Xs, there are 512 possible combinations. But only those with exactly five 1
s are valid.
We can reduce the problem to the unique number of arrangements of 4 black stones placed in 9 slots, since all the others will be white stones.
In cases where there is 1 stone placed somewhere in
N
slots, there areN
possibilities.In cases where there are 2 stones placed in
N
slots, the answer is the triangle number ofN-1
, or(N-1)N/2
.In cases where there are 3 stones placed in
N
slots, the answer is the sum ofN-2
triangle numbers, which telescopes to to(n-2)(n-1)n/6
What I cannot figure out is how to generalize this to m
stones in N
slots, where N > m
. Telescoping is always a trial-and-error process, so it would be absurd to progress sequentially from 1 to m
for, say, 100 stones distributed across 150 slots. So perhaps a more general question is: When you have a formula in which each subsequent step is the sum of a sequence of the previous step, how can you progress without solving each sequence in turn?
Another way to address the problem is to say: Of every binary number from [0000]11111
to 111110000
, how many have digits that sum to 5?