Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
"""This is a python code answers the question from Daniel Litt (@littmath) on coin tosses. | |
Link: https://x.com/littmath/status/1769044719034647001 | |
One can count the exact number of cases where Alice wins / Bob wins / or draw for given n, using dynamic programming (in other words, recursive formula). | |
In particular, the keys of the dictionary `dp` have a form of `(n, c, l)`, where `dp[(n, c, l)]` counts the number of cases where | |
1) n is the number of tosses, | |
2) c is the (score of Alice - score of Bob), | |
3) l is the last flip ('H' or 'T'). | |
Note that the number of draws is exactly the sequence A163493 of OEIS (https://oeis.org/A163493), which also appears as a Problem 11610 of AMM by Richard Stanley. | |
""" |