projects
/
cipher-tools.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e6332a1
)
Changed frequencies procedure to use a Counter object
author
Neil Smith
<neil.github@njae.me.uk>
Tue, 12 Nov 2013 11:34:09 +0000
(11:34 +0000)
committer
Neil Smith
<neil.github@njae.me.uk>
Tue, 12 Nov 2013 11:34:09 +0000
(11:34 +0000)
cipher.py
patch
|
blob
|
history
diff --git
a/cipher.py
b/cipher.py
index bc173a75200e5c1a997ec7d792f782633e154ff2..d738d8879c8e8a3c98fbc782c7a511a3a0fbf132 100644
(file)
--- 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)]
('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):
letter_frequencies = frequencies
def deduplicate(text):