Skip to content

Instantly share code, notes, and snippets.

View seewoo5's full-sized avatar
🧠
Thinking

Seewoo Lee seewoo5

🧠
Thinking
View GitHub Profile
@seewoo5
seewoo5 / sage-lecture-beamer.pdf
Last active October 11, 2024 20:08
Number theory tutorial with Sage
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@seewoo5
seewoo5 / abcd.py
Created March 19, 2024 22:34
Alice, Bob, Coin, and Dynamic Programming (or Daniel Litt)
"""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.
"""