# Disc Game Prize Fund

Solution · 8 July 2026 · [Project Euler 121](https://projecteuler.net/problem=121)

**The maximum prize is £2,269**, including the player's £1 stake.

The player needs at least eight blue draws to win. On turn $i$ the bag
holds one blue disc and $i$ red discs,
whatever was drawn earlier. Encode the red choices by $i$ and the blue
choice by $x$. In the product

$$
P(x)=(1+x)(2+x)\cdots(15+x),
$$

each choice of $x$ records one blue. The coefficient of $x^k$ counts
the draw sequences with $k$ blues, with the individual red discs counted
separately. The program below builds the coefficients one factor at a
time. Multiplying by $i+x$ gives the new coefficient of $x^k$ as $i$
times its old coefficient plus the old coefficient of $x^{k-1}$, taking
missing coefficients as zero. There are $2\cdot3\cdots16=16!$ equally
likely sequences. Adding the coefficients from $x^8$ through $x^{15}$
and dividing by $16!$ gives the winning probability

$$
p=\frac{9\,219\,406\,943}{20\,922\,789\,888\,000}.
$$

The banker collects £1 and pays $F$ pounds with probability $p$, so the
prize must satisfy $F\leq 1/p$. Dividing the denominator of $p$ by its
numerator gives a quotient of 2269 and a remainder of 3,955,534,333.
Paying £2,270 would cost more than £1 per play on average.

## C++ implementation

```cpp
#include <array>
#include <iostream>

int main() {
  constexpr unsigned turns = 15;
  std::array<std::array<unsigned long long, turns + 1>, turns + 1> weights{};
  weights[0][0] = 1;
  unsigned long long denominator = 1;

  for (unsigned turn = 1; turn <= turns; ++turn) {
    denominator *= turn + 1;
    for (unsigned blues = 0; blues <= turn; ++blues) {
      weights[turn][blues] = turn * weights[turn - 1][blues];
      if (blues > 0) {
        weights[turn][blues] += weights[turn - 1][blues - 1];
      }
    }
  }

  unsigned long long winning_weight = 0;
  for (unsigned blues = turns / 2 + 1; blues <= turns; ++blues) {
    winning_weight += weights[turns][blues];
  }
  std::cout << denominator / winning_weight << '\n';
}
```

[Problem](https://xyzmaths.org/pow/disc-game-prize-fund/index.md) · [Editorial](https://xyzmaths.org/pow/disc-game-prize-fund/editorial/index.md)
