Skip to content

Instantly share code, notes, and snippets.

@qguv
Created November 18, 2025 23:19
Show Gist options
  • Select an option

  • Save qguv/51944c3d55750f8428a05c0208bc83b0 to your computer and use it in GitHub Desktop.

Select an option

Save qguv/51944c3d55750f8428a05c0208bc83b0 to your computer and use it in GitHub Desktop.
Find good acronyms for keeping up with TODOs when booking events
#!/usr/bin/env python3
from pathlib import Path
from itertools import product
from sys import argv
def replacen(s, *args, **kwargs):
new = args.pop()
olds = args
for old in olds:
s2 = s.replace(old, new, **kwargs)
if s2 != s:
return s2
raise ValueError('none of the substrings were present')
def acronyms():
categories = [
['stay', 'accomodation', 'lodging'],
['travel/transit'],
['registration'],
['eli', 'cat', 'pets'],
['absence'],
['merch'],
['dj', 'show/stage', 'performance'],
]
for words in product(*categories):
sorted_acronym = ''.join(sorted(word[0] for word in words))
if len(set(sorted_acronym)) != len(sorted_acronym):
continue
yield (words, sorted_acronym)
english_wordlist_path = argv[1]
sorted_to_english = {}
with Path(english_wordlist_path).open('r') as f:
for line in f:
v = line.strip()
k = ''.join(sorted(v))
try:
vs = sorted_to_english[k]
except KeyError:
vs = set()
sorted_to_english[k] = vs
vs.add(v)
for words, sorted_acronym in acronyms():
try:
vs = sorted_to_english[sorted_acronym]
print(words)
for v in vs:
print('\t', v)
except KeyError:
continue
('stay', 'travel/transit', 'registration', 'eli', 'absence', 'merch', 'dj')
smarted
('stay', 'travel/transit', 'registration', 'eli', 'absence', 'merch', 'performance')
tampers
stamper
restamp
('lodging', 'travel/transit', 'registration', 'eli', 'absence', 'merch', 'show/stage')
smalter
tramels
armlets
lamster
('lodging', 'travel/transit', 'registration', 'eli', 'absence', 'merch', 'performance')
templar
trample
lampret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment