~kris/dots

srice

ref: e98f3b030dc24445bd55c68d95d2d81933fd68b3 srice/.local/bin/anagram -rw-r--r-- 419 bytes
e98f3b03 — Kris Yotam chore: sync local state after restore (push updates, no pull) a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/usr/bin/env python3
"""anagram -- find anagrams from /usr/share/dict/words"""
import sys
from collections import Counter

word = sys.argv[1].lower() if len(sys.argv) > 1 else input("word: ").lower()
target = Counter(word)

with open("/usr/share/dict/words") as f:
    for line in f:
        candidate = line.strip().lower()
        if candidate != word and Counter(candidate) == target:
            print(candidate)