Premium problem72. Sequential Glass Bridge

Hard Locked

A bridge is B steps long. Each step offers two panels, one safe and one that breaks, and nobody knows which is which. Players cross one at a time, and everything an earlier player discovers stays known to those behind.

Return the probability that player i (1-indexed) survives.

  • a player only guesses when they reach a panel nobody has tested
  • a wrong guess costs that player, but reveals the panel for good
  • so the number of players lost before the bridge is fully mapped is D∼Binomial(B,1/2)D \sim \mathrm{Binomial}(B, 1/2)

Player i survives exactly when D≤i−1D \leq i - 1.

Input

B = 18
i = 1

Output

3.814697265625e-06

Premium problem

This one's part of Premium. Unlock the full Probability track plus every other premium problem on the site.

Implement solve(...)