diff options
Diffstat (limited to 'challenge-081/roger-bell-west/python/ch-2.py')
| -rwxr-xr-x | challenge-081/roger-bell-west/python/ch-2.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/challenge-081/roger-bell-west/python/ch-2.py b/challenge-081/roger-bell-west/python/ch-2.py new file mode 100755 index 0000000000..eca8fb3cc3 --- /dev/null +++ b/challenge-081/roger-bell-west/python/ch-2.py @@ -0,0 +1,23 @@ +#! /usr/bin/python3 + +import fileinput +from itertools import chain + +c=dict() + +for line in fileinput.input(): + line=line.rstrip("\r\n") + for rep in ('--',"'s",'.','"','(',')',','): + line=line.replace(rep,' ') + for word in line.split(): + c.setdefault(word,0) + c[word] += 1 + +f=dict() +for w in sorted(c.keys()): + f.setdefault(c[w],list()) + f[c[w]].append(w) + +for n in sorted(f.keys()): + print(' '.join((list(str(n)) + f[n]))) + print('') |
