Created
November 22, 2020 17:19
-
-
Save michaelochurch/84ac5e8d04af56a64e9972678db496c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> 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