A bag contains one red disc and one blue disc. In a game of chance a
player takes a disc at random and its colour is noted. After each turn
the disc is returned to the bag, an extra red disc is added, and another
disc is taken at random.
The player pays to play and
wins if they have taken more blue discs than red discs at the end of the
game.
If the game is played for four turns, the probability of a player
winning is exactly ,
and so the maximum prize fund the banker should allocate for winning in
this game would be before they
would expect to incur a loss. Note that any payout will be a whole
number of pounds and also includes the original paid to play the game, so in the
example given the player actually wins .
Find the maximum prize fund that should be allocated to a single game
in which fifteen turns are played.
for i inrange(1, N + 1): ls = [0for j inrange(i + 1)] f.append(ls) for j inrange(i + 1): if j > 0: f[i][j] += f[i - 1][j - 1] * 1 / (i + 1) if j < i: f[i][j] += f[i - 1][j] * i / (i + 1) ans = 0 for j inrange(N + 1): if j > N - j: ans += f[N][j] ans = int(1 / ans) print(ans)