diff options
| author | Zach DeCook <zach.decook@bettercarpeople.com> | 2026-08-17 08:25:23 -0400 |
|---|---|---|
| committer | Zach DeCook <zach.decook@bettercarpeople.com> | 2026-08-17 08:25:23 -0400 |
| commit | c17744a5e900f5a2198d6a5a782c4dfd9c4ec98e (patch) | |
| tree | 4dcbf70c23945152c554b11f24bbad4c88faaf07 /zanagrams/onceletters.py | |
| parent | 958665b368ca1534ff9db0dcbf5c704a614ae23e (diff) | |
| download | gurglesolver-c17744a5e900f5a2198d6a5a782c4dfd9c4ec98e.tar.gz | |
Add zanagrams solver zanagrams
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) + |
