Problem:
Let be the number of ways in which the letters in "HMMTHMMTHMMTHMMTHMMTHMMT" ("HMMT" repeated six times) can be rearranged so that each letter is adjacent to another copy of the same letter. For example, "MMMMMMTTTTTTHHHHHHHHHHHH" satisfies this property, but "HMMMMMTTTTTTHННННННННННМ" does not. Estimate .
An estimate of will earn points.
, 2021
Solution
Solution:
We first count the number of arrangements for which each block of consecutive identical letters has even size. Pair up the letters into 3 pairs of , 6 pairs of , and 3 pairs of , then rearrange the pairs. There are ways to do this.
In the original problem, we may estimate the number of arrangements by computing the fraction of arrangements with all even blocks. We estimate this by counting the number of ways to split the 6 s, 12 s, and 6 s into blocks, and collating the proportions of splittings which use all even blocks:
- We can split 6 as , , , and . Exactly of the splittings have all even blocks.
- We can split 12 into , , , , , , , , , , , , , , , , , .
Stars and bars to expand from the pairs variant gives 79000.
The following C++ code outputs the exact answer:
```
#include <bits/stdc++.h>
using namespace std;
#define IJK iii[0]][iii[1]][iii[2]
#define ijk i][j][k
#define MAX_N 100
#define S 3
#define N 6
long long dp[2][3][MAX_N][MAX_N][MAX_N];
int main()
{
dp[1][0][0][0][0] = 1;
for (int i = 0; i <= N; i++)
for (int j = 0; j <= 2*N; j++)
for (int k = 0; k <= N; k++)
for (int c = 0; c < S; c++)
for (int l = 0; l < S; l++)
{
int iii[] = { i, j, k }; iii[l]++;
dp[0][l][IJK] += (c != l || !(i + j + k)) * dp[1][c][ijk];
dp[1][l][IJK] += (c == l && i + j + k) * (dp[1][c][ijk] + dp[0][c][ijk]);
}
long long a = 0;
for (int i = 0; i < S; i++) a += dp[1]*[N][2 * N][N];
cout << a << endl;
return 0;
}
```