Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View letters.py
1 2 3 4 5 6 7 8 9 10 11 12
#!/usr/bin/env python3
# Counts the amount of letters in a file.
# In this case, used to count the concentration of letters in English.
import string
from collections import Counter
 
c = Counter(string.ascii_lowercase + string.ascii_uppercase)
 
with open('/usr/share/dict/words', 'r') as words:
for word in words:
map(lambda l: c.__setitem__(l, c[l] + 1), tuple(word.strip())) # Tuples are faster than lists
print c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.