Last active
November 4, 2022 18:17
-
-
Save jsundram/3abc6a3b931d9edb7057b95d56641b14 to your computer and use it in GitHub Desktop.
Solving the Spelling Bee (https://www.nytimes.com/puzzles/spelling-bee) with a one-liner in Bash
This file contains hidden or 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 bash | |
# Solve the Spelling Bee (https://www.nytimes.com/puzzles/spelling-bee) | |
# Usage `./bee.sh ulroapn | more` where the first letter is the one in the middle | |
# Output: a list of valid dictionary words that contain the first letter and | |
# no letters that aren't on the list provided. | |
# Unfortunately the MacOS dictionary has words that aren't in the custom | |
# Spelling Bee dictionary, so you may find words listed that aren't accepted | |
# by the spelling bee app. | |
letters=$1 | |
center=${letters:0:1} # Assumes first letter is the middle one | |
# This used to be a one-liner but I decided to make it more readable. | |
egrep -w "^[$letters]+" /usr/share/dict/words | grep $center | # Get all the words that match | |
awk -v number= '{ if (length > 3) print length, $0 }' | # Prefix them with their length if they are longer than 3 letters | |
sort -rn | # Sort numerically in reverse (longest first) | |
cut -d" " -f2- # Remove the length prefix. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alternatively, just do
window.gameData.today.answers
in the javascript console. Or, to have it sorted nicely: