Skip to content

Instantly share code, notes, and snippets.

@dan-compton dan-compton/blah.py

Created Nov 18, 2015
Embed
What would you like to do?
import collections
import pprint
import operator
d = collections.defaultdict(int)
z = {}
original = '''FNNVRJAINVMUHZBJLTXFEMNVAINVMUOWUCNVNVRJCKXFWELTNVWXTZMUAIBJ'''
print 'total chars:',len(original)
for c in original:
d[c] += 1
sorted_x = sorted(d.items(), key=operator.itemgetter(1))
print 'count: '
pprint.pprint(sorted_x)
for key in d:
z[key] = float(d[key])/float(len(original))
sorted_x = sorted(z.items(), key=operator.itemgetter(1))
print 'frequency: '
pprint.pprint(sorted_x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.