Skip to content

Instantly share code, notes, and snippets.

@LunaticNeko
Created March 5, 2019 12:08
Show Gist options
  • Save LunaticNeko/cf4ae3b4f5a2a68f057bc7c0740bcc17 to your computer and use it in GitHub Desktop.
Save LunaticNeko/cf4ae3b4f5a2a68f057bc7c0740bcc17 to your computer and use it in GitHub Desktop.
Analyzes digit distribution of pi from a plaintext file.
with open('pi-billion.txt') as f:
f.read(2)
count = [0]*10
while True:
s = f.read(1000000).strip()
if not s:
break
for c in s:
count[int(c)] += 1
print(count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment