Skip to content

Instantly share code, notes, and snippets.

@bsolomon1124
Created June 22, 2018 16:21
Show Gist options
  • Save bsolomon1124/570688923daefcc99c69e8d8a15ddabf to your computer and use it in GitHub Desktop.
Save bsolomon1124/570688923daefcc99c69e8d8a15ddabf to your computer and use it in GitHub Desktop.
`os.urandom()` maps to ints in [0, 255]
# Informal proof
from math import inf
mn, mx = inf, -1 * inf
for _ in range(100000):
b = os.urandom(10)
new_min = min(b)
new_max = max(b)
if new_min < mn:
mn = new_min
if new_max > mx:
mx = new_max
if __name__ == '__main__':
print(mn, mx)
# (0, 255)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment