Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
#!/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.