Skip to content

Instantly share code, notes, and snippets.

@Plutor
Last active August 31, 2015 13:12
Show Gist options
  • Save Plutor/2e7dcbb777abeb896c32 to your computer and use it in GitHub Desktop.
Save Plutor/2e7dcbb777abeb896c32 to your computer and use it in GitHub Desktop.
Longest words spellable with alphabet blocks minus a word
# We own a set of alphabet blocks. There are 24 of them: one letter on each
# (with drawings of things that start with that letter), and X, Y, and Z are all
# on one block. We took the letters for our daughters name (no repeats, phew!)
# and they sit on a shelf in her room. The rest are with her toys in the living
# room.
#
# Here's how I figured out the longest words I could spell with the remaining
# blocks (buchwald, plutarch, abruptly, upwardly, watchful, and wrathful).
cat $WORDFILE | # Replace with a word file on your machine, probably one in /usr/share/dict/ \
tr '[A-Z]' '[a-z]' | # Convert all to lowercase \
grep -v '[removedword]' | # Remove words that contain the letters from a word \
grep -v '\(.\).*\1' | # Remove words with one letter more than once \
grep -v '[xyz].*[xyz]' | # Remove words with more than one of [xyz] \
awk '{ print length, $0 }' | sort -n -s -r | cut -d" " -f2- | # Sort by length \
head -20 # Just show the top 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment