Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
>>> def dp():
... r = random.randint(1, 8)
... if r < 4: return 0
... if r < 7: return 1
... if r == 7: return 2
... if r == 8:
... out = 3
... while random.randint(1, 8) == 8:
... out += 1
... return out
>>> def ndP(n):
... return sum(dp() for x in range(n))
>>> def med_ndP(m, n):
... res = [ndP(n) for x in range(m)]
... res.sort()
... return res[m // 2]
>>> results = [med_ndP(3, 4) - (4 + med_ndP(3, 4)) for x in range(100000)]
>>> len([x for x in results if x > 0])
1331
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment