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).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | $ # 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.
|