Last active
October 21, 2024 02:03
-
-
Save scruss/d0f1a3a81cf021d2d7f0c1fc4e842bc9 to your computer and use it in GitHub Desktop.
threes.py - re-split several 3-letter words into (several-1) new 3-letter words
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
# scruss, 2024-10 | |
from itertools import combinations | |
from textwrap import wrap | |
import random | |
random.seed(None) | |
COUNT = 5 # your number of 3 letter words to string together | |
# I don't recommend going above 5 because it gets really slow | |
# 'was per age two now law ⇒ asp era get won owl', tho ... | |
matches = {} # all of the known three letter words | |
seen = {} # so we don't get duplicate results | |
# top 50 three letter words in Wikipedia | |
c = ( | |
"age air all and any are but can day did " | |
"due end few for had has her him his how " | |
"its law led low man may men new not now " | |
"off old one out own per run see set she " | |
"six the too two use war was way who you" | |
) | |
common = c.split(" ") | |
for i in common: | |
matches[i] = 1 | |
random.shuffle(common) | |
# there are probably easier ways to ingest /usr/dict/words | |
# three letter words - arbitrarily edited by me | |
for i in ( | |
"ace act add ado ads adv aft age ago aha " | |
"aid ail aim air ale all alt amp and " | |
"ani ant any ape app arc are ark arm art " | |
"ash ask asp ass ate auk awe awl axe aye " | |
"baa bad bag bah ban bar bat bay bed bee beg " | |
"bet bib bid big bin bit boa bob bog boo bop " | |
"bot bow box boy bra bud bug bum bun " | |
"bus but buy bye cab cad cam can cap " | |
"car cat caw cis cob cod cog col con coo " | |
"cop cot cow cox coy cry cub cud cue cum cup " | |
"cur cut dab dad dam day deb den dew did " | |
"die dig dim din dip doc doe dog don " | |
"dot dry dub dud due dug dun duo " | |
"dye ear eat ebb eel egg ego eke elf elk " | |
"ell elm emo emu end eon era ere erg err " | |
"etc eve ewe eye fad fag fan far " | |
"fat fax fed fee fen few fey fez fib " | |
"fie fig fin fir fit fix flu fly fob foe fog " | |
"foo fop for fox fro fry fun fur " | |
"gab gad gag gal gap gas gay gee gel gem gen " | |
"get gig gin gnu gob god goo got gum gun " | |
"gut guy gym had hag hah ham has hat haw " | |
"hay hem hen hep her hew hex hey hid " | |
"hie him hip his hit hob hoc hod hoe hog hop " | |
"hot how hrs hub hue hug hum hut " | |
"ice icy ilk ill imp inc ink " | |
"inn ins int ion ire irk ism its ivy jab jag " | |
"jam jar jaw jay jet jib jig job jog jot joy " | |
"jug jut keg ken key kid kin kit lab lad lag " | |
"lam lap lat law lax lay lea led lee leg " | |
"lei let lib lid lie lip lit lob log " | |
"lop lot low lox lug lye mad man map " | |
"mar mat maw max may med meg men " | |
"met mew mid mil min mix mob mod mom " | |
"moo mop mow mud mug mum nab nag " | |
"nap nay neg net new nib nil nip nit nix nod " | |
"non nor not now nub nun nut oaf oak " | |
"oar oat obj odd ode off oft ohm oil " | |
"old one ops opt orb orc ore our out ova owe " | |
"owl own pad pal pan pap par pas pat paw pay " | |
"pea pee peg pen pep per pet pew pie pig " | |
"pin pip pis pit pkg ply pod poi pol pop pot " | |
"pox pro pry pub pug pun pup pus put pwn pyx " | |
"qua rag ram ran rap rat raw ray red ref rep " | |
"rev rho rib rid rig rim rip rob rod roe rot " | |
"row rub rue rug rum run rut rye " | |
"sac sad sag sap sat saw sax say sea sec see " | |
"set sew sex she shy sic sim sin sip sir sis " | |
"sit six ski sky sly sob sod son sop " | |
"sot sow sox soy spa spy sty sub sue sum sun " | |
"sup tab tad tag tam tan tap tar tat tax " | |
"tea tee ten the tho thy tic tie tin tip " | |
"tit toe tog tom ton too top tor tot tow toy " | |
"try tub tug tun tux two ugh ump ups urn " | |
"use van var vat vet vex via vie vim viz " | |
"vol vow wad wag wan war was wax way web wed " | |
"wee wen wet who why wig win wit wiz woe wok " | |
"won woo wot wow wry xor " | |
"yak yam yap yaw yea yen yep yes " | |
"yet yew yip yon you yuk yum yup zap zed " | |
"zen zip zit zoo" | |
).split(" "): | |
matches[i] = 1 | |
for j in combinations(common, COUNT): | |
i = "".join(j) | |
for x in range(2): | |
k = 0 | |
m = wrap(i[1 + x : 3 * (COUNT - 1) + 1 + x], 3) | |
mj = " ".join(m) | |
for w in m: | |
if w in matches: | |
k = k + 1 | |
if k == (COUNT - 1): | |
if mj not in seen: | |
seen[mj] = 1 | |
print(" ".join(j), "⇒", mj) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
has set can two new ⇒ ass etc ant won | |
has how low now not ⇒ ash owl own own | |
has how low now law ⇒ ash owl own owl | |
has how low now end ⇒ ash owl own owe | |
has how low law end ⇒ ash owl owl awe | |
has how low law led ⇒ ash owl owl awl | |
has how now law end ⇒ ash own owl awe | |
has how now law led ⇒ ash own owl awl | |
has her are per air ⇒ ash era rep era | |
has her are per end ⇒ ash era rep ere | |
has see low now not ⇒ ass eel own own | |
has see low now law ⇒ ass eel own owl | |
has see low now end ⇒ ass eel own owe | |
has see low law end ⇒ ass eel owl awe | |
has see low law led ⇒ ass eel owl awl | |
has him per air end ⇒ ash imp era ire | |
has him per age new ⇒ ash imp era gen | |
has she now law end ⇒ ass hen owl awe | |
has she now law led ⇒ ass hen owl awl | |
has she war the may ⇒ ass hew art hem | |
has she war the who ⇒ ass hew art hew | |
has she war the new ⇒ ass hew art hen | |
has she war can two ⇒ ass hew arc ant | |
has she war two new ⇒ ass hew art won | |
has she was per air ⇒ ass hew asp era | |
has she was per end ⇒ ass hew asp ere | |
has she was had six ⇒ ass hew ash ads | |
has she was had off ⇒ ass hew ash ado | |
has she was his man ⇒ ass hew ash ism | |
has she you the may ⇒ ass hey out hem | |
has she you the who ⇒ ass hey out hew | |
has she you the new ⇒ ass hey out hen | |
has she you two new ⇒ ass hey out won | |
has she per air end ⇒ ass hep era ire | |
has she per age new ⇒ ass hep era gen | |
has she who two new ⇒ ass hew hot won | |
set how its own age ⇒ tho wit sow nag | |
how low now law end ⇒ owl own owl awe | |
how low now law led ⇒ owl own owl awl | |
her are per air end ⇒ era rep era ire | |
her are per age new ⇒ era rep era gen | |
see low now law end ⇒ eel own owl awe | |
see low now law led ⇒ eel own owl awl | |
one war the who two ⇒ new art hew hot | |
one war can two new ⇒ new arc ant won | |
one was per air end ⇒ new asp era ire | |
one was per age new ⇒ new asp era gen | |
one the who two new ⇒ net hew hot won | |
she war the who two ⇒ hew art hew hot | |
she war can two new ⇒ hew arc ant won | |
she was per air end ⇒ hew asp era ire | |
she was per age new ⇒ hew asp era gen | |
she you the who two ⇒ hey out hew hot | |
war the who two new ⇒ art hew hot won | |
you the who two new ⇒ out hew hot won |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment