Skip to content

Instantly share code, notes, and snippets.

@pervognsen
Created March 3, 2010 09:28
Show Gist options
  • Save pervognsen/320475 to your computer and use it in GitHub Desktop.
Save pervognsen/320475 to your computer and use it in GitHub Desktop.
def normalize(word):
return word.lower()
def coordinates(word):
word = normalize(word)
coords = [0] * 26
for char in word:
coords[ord(char) - ord('a')] += 1
return tuple(coords)
words = []
histogram = {}
for word in open("/usr/share/dict/words"):
word = word.strip()
words.append(word)
coords = coordinates(word)
histogram[coords] = 1 + histogram.get(coords, 0)
print len(words)
print len(histogram)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment