ElBlo
Solving NYTimes Spelling Bee
The NYTimes Spelling Bee is a game that consists of creating words from a given set of letters. You get one center letter, and 6 “outside” letters.
Here are the rules:
- Words must contain at least 4 letters.
- Words must include the center letter.
- Our word list does not include words that are obscure, hyphenated, or proper nouns.
- No cussing either, sorry.
- Letters can be used more than once.
- 4-letter words are worth 1 point each.
- Longer words earn 1 point per letter.
- Pangrams use each letter at least once. These are worth 7 extra points.
For example, today’s letters are: N
, O
, L
, A
, E
, H
, and the center
letter is G
. Some valid words are GALLEON
, ANGEL
, or the pangram
HALOGEN
.
In an attempt to ruin the fun for everyone, this game can be solved with a simple regexp:
$ grep -E "^[enalohg]*g[enalohg]*$" /usr/share/dict/american-english | grep -E "^.{4,}$"
agog
alga
algae
allege
along
analog
angel
(...)
Note that looking for pangrams can be done with extra calls to grep
, but
doing it with a regexp is tedious, as you have to take into account all
possible letter orderings.