Skip to content

Instantly share code, notes, and snippets.

@ricbit
Created April 17, 2021 01:42
Show Gist options
  • Save ricbit/5e30001b73b0c385c1a44d08e7ef4306 to your computer and use it in GitHub Desktop.
Save ricbit/5e30001b73b0c385c1a44d08e7ef4306 to your computer and use it in GitHub Desktop.
Expected number of packs to complete an album (linear)
import math
evalue = [0] * 181
norm = math.comb(180, 4)
for i in range(1, 181):
ans = math.comb(i, 0) * math.comb(180 - i, 4 - 0) / norm
for k in range(1, 5):
if i - k >= 0:
px = math.comb(i, k) * math.comb(180 - i, 4 - k) / norm
ans += px * (1 + evalue[i - k])
ans /= 1 - math.comb(180 - i, 4) / norm
evalue[i] = ans
print(i, evalue[i])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment