Skip to content

Instantly share code, notes, and snippets.

@atoponce
Created January 19, 2022 00:41
Show Gist options
  • Save atoponce/d2671625751c3e159624867af3563ecf to your computer and use it in GitHub Desktop.
Save atoponce/d2671625751c3e159624867af3563ecf to your computer and use it in GitHub Desktop.

Start with "STAIN":

stain

"S" is in the solution but in a different spot. "T", "A", "I", and "N" are not in the solution.

$ grep -P '(?=^[^stain][^tain]{4}$)(?=.*s.*)(?!.*[[:punct:]].*)' /usr/share/dict/words

Guess with "YOURS":

yours

"Y" and "R" are not in the solution. "O" and "U" are in the solution and in the correct spots. "S" is in the solution but in a different spot.

$ grep -P '(?=^[^yrstain]ou[^yrtain][^tainyrs]$)(?=.*s.*)(?!.*[[:punct:]].*)' /usr/share/dict/words

Guess with "HOUSE":

house

"H" is not in the solution. "O", "U", "S", and "E" are in the solution and in the correct spots.

$ grep -P '(?=^[^hyrstain]ouse$)(?!.*[[:punct:]].*)' /usr/share/dict/words

Guess with "MOUSE":

mouse

"M" is not in the solution. "O", "U", "S", and "E" are in the solution and in the correct spots.

$ grep -P '(?=^[^mhyrstain]ouse$)(?!.*[[:punct:]].*)' /usr/share/dict/words

Guess with "DOUSE":

douse

"D" is not in the solution. "O", "U", "S", and "E" are in the solution and in the correct spots.

$ grep -P '(?=^[^dmhyrstain]ouse$)(?!.*[[:punct:]].*)' /usr/share/dict/words

Guess with "LOUSE":

louse

We win. "LOUSE" is the solution.

finished

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment