X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=cipher.py;h=d738d8879c8e8a3c98fbc782c7a511a3a0fbf132;hb=c9acecf59f93004d33c19b209535072dcf932977;hp=bc173a75200e5c1a997ec7d792f782633e154ff2;hpb=e6332a16567643e66c2a491b94994f9482384d34;p=cipher-tools.git diff --git a/cipher.py b/cipher.py index bc173a7..d738d88 100644 --- a/cipher.py +++ b/cipher.py @@ -120,11 +120,14 @@ def frequencies(text): ('h', 2), ('i', 1), ('j', 1), ('k', 1), ('l', 1), ('m', 1), ('n', 1), ('o', 4), ('p', 1), ('q', 1), ('r', 2), ('t', 2), ('u', 2), ('v', 1), ('w', 1), ('x', 1), ('y', 1), ('z', 1)] + >>> frequencies('abcdefabcdef')['x'] + 0 """ - counts = collections.defaultdict(int) - for c in text: - counts[c] += 1 - return counts + #counts = collections.defaultdict(int) + #for c in text: + # counts[c] += 1 + #return counts + return collections.Counter(c for c in text) letter_frequencies = frequencies def deduplicate(text):