# read one word per line from stdin; print sets of words that contain all specified letters;
# hint: use output from pangramwords.py as input
import string, sys
LETTERS = set(string.ascii_lowercase + "åäöšž")
MAX_TOTAL_LENGTH = 59 # maximum total number of letters
words = {line.rstrip("\n") for line in sys.stdin}
# group words by set of letters
letterSets = {}
for word in words:
letterSet = frozenset(set(word.lower()) & LETTERS)
try:
letterSets[letterSet].add(word)
except KeyError:
letterSets[letterSet] = set((word,))
# get length of shortest word in each set of letters
shortestWordInLetterSet = dict((s, min(len(w) for w in letterSets[s])) for s in letterSets)
# optimization: no word has more than one of q/w/x/š/ž, so we need at least one of each set
setsQ = set(s for s in letterSets if "q" in s)
setsW = set(s for s in letterSets if "w" in s)
setsX = set(s for s in letterSets if "x" in s)
setsSH = set(s for s in letterSets if "š" in s)
setsZH = set(s for s in letterSets if "ž" in s)
# optimization: there's only one word with "å"
set0 = frozenset("ångström")
left0 = LETTERS - set0
# letter sets with q
for set1 in setsQ:
left1 = left0 - set1
# letter sets with w
for set2 in setsW:
left2 = left1 - set2
# letter sets with x
for set3 in setsX:
left3 = left2 - set3
# letter sets with š
for set4 in setsSH:
left4 = left3 - set4
# letter sets with ž
for set5 in setsZH:
left5 = left4 - set5
if not left5:
sets = (set0, set1, set2, set3, set4, set5)
if sum(shortestWordInLetterSet[s] for s in sets) <= MAX_TOTAL_LENGTH:
print(" + ".join(sorted(
"/".join(sorted(letterSets[s])) for s in sets
)))