Example Manual Pangram Game

See also:

Note that in the listing below I have marked the commands and responses to the command-line shell "bash" as plain text of type 'console' so the markdown engine that renders the text into HTML can try to make it look nice. You may see line numbers at the very left - these are inserted by the markdown rendering engine; they're not part of the bash command session.

Also note I've arbitrarily inserted some blank lines to try to make the transcript below easy to read. And I've liberally faked some of the lines and moved things around etc. to make my point(s).

$ # Some warm-up commands... 'ls' lists files and directories.

$ ls data
A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z

$ ls -F data # the -F option to ls puts trailing slashes '/' to show subdirs
A/  C/  E/  G/  I/  K/  M/  O/  Q/  S/  U/  W/  Y/
B/  D/  F/  H/  J/  L/  N/  P/  R/  T/  V/  X/  Z/

$ ls data/A
AAHED-AAPAS  ABBED-ABBEY  ABRAY-ABRIS  ADULT-ADYTS  ASCOT-ASCUS  AVIZE-AVOWS
AARGH        ABBOT-ABCEE  ABSIT-ACEDY  ADZED-AESIR  ASHED-ASHES  AVYZE-AWING
AARTI        ABEAM-ABELE  ACENE-ACHED  AEVUM-AFEAR  ASHET-ASITY  AWKIN-AWNED
ABACA        ABENG        ACHER-ACIES  AFFIX-AFIZZ  ASKER        AWNER-AXMAN
ABACI        ABERS-ABETS  ACING-ACOEL  AFLAJ-AFOOT  ASKEW-ASSOT  AXMEN-AYELP
ABACK        ABEYS        ACOLD-ACRAL  AFORE-AFTOS  ASTUN-ATMOS  AYGRE-AZIDO
ABACS        ABHOR-ABIES  ACRED-ACTAS  AGAIN-AGASP  ATOKE-ATTAR  AZINE-AZOLE
ABAFT        ABIUS-ABJAD  ACTED-ADHAN  AGAST-AGBAS  ATTAS-ATUAS  AZONS-AZOTH
ABAHT        ABJUD-ABLET  ADHOC-ADITS  AQUAE        AUCHT-AULOS  AZUKI-AZURN
ABAKA        ABLOW-ABNET  ADLIB-ADMEN  AQUAS-ARARS  AUMIL-AUXIN  AZURY-AZYMS
ABAMP        ABODE-ABORN  ADMIN-ADMIT  ARBAH        AVAIL        
ABAND        ABORT        ADMIX-ADOON  ARBAS        AVALE        
ABASE-ABASH  ABOUT        ADOPT-ADOZE  ARBOR        AVANT        
ABASK        ABOVE        ADRAW-ADSUM  ARCHI        AVAST        
ABATE-ABBAS  ABRAM        ADUKI        ASCON        AVELS-AVISO

$ # The '#' character means "the rest of this line is a comment" to bash
$ # So if we want to grep for '#' we must enquote it like '#'
$ grep '#' data/A/AARGH
# AARGH = 900

$ # It also means that the line just above here, which is the output
$ # from the 'grep' command, is rendered by the markdown engine like
$ # it was a command. Programs are only as smart as we make them...

$ # I should perhaps mention that 'grep' is a program that searches
$ # line-oriented text data files and emits every line that matches
$ # a given pattern (or if given the '-v' option, every line that
$ # does NOT match the pattern). End of tutorial, go search for more.

$ # Anyhoo, in the pangram data files there is one line for each start
$ # word, that gives the number of base pangrams found when that word
$ # was used as the first word to search from. Those lines start with
$ # a '#' followed by the word, an equal sign, and the number.

$ ls data/P
PAAHO-PZAZZ

$ # There's only one file in the P data subdir because of optimization
$ # which means most of the work (> 50%) is in A,B,C and comparatively
$ # little is in each subsequent letter.

$ grep '#' data/P/PAAHO-PZAZZ | wc -l # 'wc -l' counts lines in its input
613

$ # There are 613 "count" lines in our one and only P data file.
$ # Guess how many Wordleable words start with P (after eliminating
$ # all but one anagram of each anagram set)? Ding ding ding!

$ wc -l data/P/PAAHO-PZAZZ 
6330 data/P/PAAHO-PZAZZ

$ # But there are 6330 lines total. So how many pangrams were found
$ # starting from P-words?

$ grep -v '#' data/P/PAAHO-PZAZZ | wc -l
5717

$ # That many. Here's an example of the silliest calculator to
$ # double check that:

$ expr 6330 - 613 # JK, 'expr' can be useful. Just not like this ;)
5717

$ # OK let's get serious. I'm going to let the shell pick a random
$ # archive game to play in the range of #39 to #400

$ shuf -i 39-400 -n 1
258

$ # Alrighty, I'm going to play Wordle #258 and try to win with
$ # a pangram using the pangram data files, narrating as we go.

$ # STOP READING NOW IF YOU DON'T WANT TO SPOIL Wordle #258!

$ # Just for kicks, let's count how many lines of pangram data we
$ # are starting with...
$ grep -hv '#' data/*/* | wc -l
16241610

$ # Oh yeah, a reminder to use the '-h' option to grep to avoid
$ # printing file names in the resulting output. Here's what
$ # we are avoiding:

$ grep -v '#' data/*/* | head -3
data/A/AAHED-AAPAS:[AAHED|AHEAD|HADED] BANTZ GRUMP JOCKY VEXIL WAQFS
data/A/AAHED-AAPAS:[AAHED|AHEAD|HADED] BLITZ GRUMP JOCKY VIXEN WAQFS
data/A/AAHED-AAPAS:[AAHED|AHEAD|HADED] BLONX CEZVE GRYPT MUJIK WAQFS

$ # And here's what we get instead:
$ # ('head -3' grabs the first three lines and discards the rest)

$ grep -hv '#' data/*/* | head -3
[AAHED|AHEAD|HADED] BANTZ GRUMP JOCKY VEXIL WAQFS
[AAHED|AHEAD|HADED] BLITZ GRUMP JOCKY VIXEN WAQFS
[AAHED|AHEAD|HADED] BLONX CEZVE GRYPT MUJIK WAQFS

$ # OK enough stalling. I'm starting with WAQFS...

$ grep -hv '#' data/*/* | grep WAQFS | wc -l
3978162

$ # Wow, already I've eliminated about 12 million pangrams. Bummer.
$ # Let's get going. Wordle #258 was played on March 4th 2022. Nice!

$ # OK, I got a yellow A and nothing else. VOZHD is the second-most
$ # common word in pangrams, meaning it should leave me lots of
$ # choices of pangrams still, and I'll get some information about
$ # the solution out of it too. Let's see what the numbers say:

$ grep -hv '#' data/*/* | grep WAQFS | grep VOZHD | wc -l
896718

$ # Bummer, we drop all the way to only about 900K pangrams left.
$ # Remember, I NEED one of those pangrams to contain the solution
$ # for this game in order to win with a pangram. What would happen
$ # if I picked some EAROT-compliant word second, say CARLE?

$ grep -hv '#' data/*/* | grep WAQFS | grep CARLE | wc -l
23

$ # Yikes, that's double-plus ungood. Let's go with VOZHD...
$ # Wahoo! we got a yellow H and green D out of VOZHD!
$ # My board looks like this:
$ #     W A Q F S
$ #    ⬜🟨⬜⬜⬜
$ #     V O Z H D
$ #    ⬜⬜⬜🟨🟩
$
$ # Hmm, looks like the solution could be HEARD, let's
$ # find out if there's any hope of a pangram with HEARD:

$ grep -hv '#' data/*/* | grep WAQFS | grep VOZHD | grep HEARD | wc -l
0

$ # Dang, and just like that I think this game could be over with
$ # no pangram win possible, just a ho-hum three. Can I think
$ # of anything else the solution could be? ⏳ ⏳ ⏳

$ # HEXAD? hope springs eternal...
$ grep -hv '#' data/*/* | grep WAQFS | grep VOZHD | grep HEXAD | wc -l
22

$ # There are some pangrams, but really it's not likely...
$ # ACHED? Darn, nope of course not. ooh, what about AHEAD?

$ grep -hv '#' data/*/* | grep WAQFS | grep VOZHD | grep AHEAD | wc -l
0

$ # Drat, foiled again. See how lucky I was in those first two games?
$ # Now I'm cheating a little, looking at PU hoping for a miracle...
$ # HOARD? Nope, no O says VOZHD. CHARD?

$ grep -hv '#' data/*/* | grep WAQFS | grep VOZHD | grep CHARD | wc -l
0

$ # Grrr. Just out of curiosity, how many pangrams DO contain
$ # CHARD, HEARD, or AHEAD?

$ grep -hv '#' data/*/* | grep CHARD | wc -l
971

$ grep -hv '#' data/*/* | grep HEARD | wc -l
249

$ grep -hv '#' data/*/* | grep AHEAD | wc -l
6

$ # Ah, six is a nice small number, let's see all of those:

$ grep -hv '#' data/*/* | grep AHEAD
[AAHED|AHEAD|HADED] BANTZ GRUMP JOCKY VEXIL WAQFS
[AAHED|AHEAD|HADED] BLITZ GRUMP JOCKY VIXEN WAQFS
[AAHED|AHEAD|HADED] BLONX CEZVE GRYPT MUJIK WAQFS
[AAHED|AHEAD|HADED] BROCK GLITZ JUMPY VIXEN WAQFS
[AAHED|AHEAD|HADED] CRONK GLITZ JUMPY VIBEX WAQFS
[AAHED|AHEAD|HADED] GLAMP JOCKY NURTZ VIBEX WAQFS

$ # Here you can see how the data represents anagrams.
$ # Notice that all six base pangrams containing AHEAD
$ # also contain WAQFS.

$ # Let's see how good my chances were of each of the
$ # other two solutions I've thought of so far, after
$ # I played WAQFS:

$ grep -hv '#' data/*/* | grep CHARD | grep WAQFS | wc -l
687

$ grep -hv '#' data/*/* | grep HEARD | grep WAQFS | wc -l
212

$ # Not bad at all, actually. Just VOZHD caused trouble.
$ # Maybe VIBEX would have been a better second choice?

$ grep -hv '#' data/*/* | grep HEARD | grep WAQFS | grep VIBEX | wc -l
90

$ grep -hv '#' data/*/* | grep CHARD | grep WAQFS | grep VIBEX | wc -l
36

$ # Looks like in this case VIBEX might have kept my game alive.
$ # After more PU scanning, I see APHID is in play. Any hope?

$ grep -hv '#' data/*/* | grep WAQFS | grep VOZHD | grep APHID | wc -l
0

$ # AARGH. I think I should just try to win now and give up on the
$ # pangram. Rats!

$ # Ooh, not-so-subtle point about APHID, look here:

$ grep -hv '#' data/*/* | grep APHID | wc -l
0

$ # Why is APHID not in any pangrams? Because we haven't searched
$ # starting from APHID yet (look above in the data/A listing and
$ # notice the big gap from AGBAS to AQUAE; words between them
$ # haven't been used to start a search for pangrams yet...  check
$ # back in a year or so!), and none of the A-searches from earlier
$ # in the alphabet found a pangram containing APHID, and none of
$ # the searches starting from later words will even check APHID
$ # since the search proceeds only to lexically-greater words at
$ # each step (the major optimization of the search time to avoid
$ # testing duplicate permutations of the same set of words again).

$ # OK, I won't actually reveal the rest of this game, I gave up
$ # and solved in two more steps. No pangram win for me this day!

$ # Would having another 20 million or so pangrams to play with
$ # have helped? Maybe. Would having a more sophisticated helper
$ # program kept my chances alive for longer? Probably. Maybe.

$ # I'm thinking the helper program should take as input the
$ # words you've guessed so far, and then tell you how many
$ # pangrams remain that contain ANY known solution words
$ # (possibly filtered by PU, maybe optionally?) and what the
$ # most common 10 unplayed words are in those remaining pangrams.
$ # I don't want the helper to solve the game for you, but just
$ # to help you keep as many options open for as long as possible.
$ # Oh, and it should let you search that remaining set of
$ # pangrams for any one word at a time, too, so you can see
$ # what pangram path(s) might lead to solutions you think are
$ # in play. Not *too* hard to write such a program, but just
$ # hard enough that I haven't done it yet. Check back in a year.

$ # So long for now, thanks for reading this far. Cheers! 🍻

$ # PS - checking the bot afterward, I had considered all 5 WL
$ # above after VOZHD, which included the super unlikely ACHED.
Edit
Pub: 14 Dec 2024 23:23 UTC
Edit: 15 Dec 2024 19:10 UTC
Views: 73