diff options
Diffstat (limited to 'zanagrams/onceletters.py')
| -rwxr-xr-x | zanagrams/onceletters.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/zanagrams/onceletters.py b/zanagrams/onceletters.py new file mode 100755 index 0000000..ede75db --- /dev/null +++ b/zanagrams/onceletters.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 +import sys + +def main(argv): + #print(argv[2], file=sys.stderr) + allowed_times = int(argv[2]) if len(argv) > 2 else 1 + #print(allowed_times, file=sys.stderr) + while 1: + letters_counts = {} + line = sys.stdin.readline() + noprint = False + if not line: + break; + for c in line: + #print(c) + c = c.casefold() + letters_counts[c] = letters_counts.get(c, 0) + 1 + if letters_counts[c] > allowed_times and c in argv[1]: + #print('oops') + noprint = True + break + if line and not noprint: + print(line, end='') + +if __name__ == '__main__': + main(sys.argv) + |
