codingquest

Wordle with friends

Some trends refuse to die. For a brief moment in 2022 a game called Wordle trended as a popular word guessing game.

In 2222, during a moment of boredom during your voyage, you and your friends onboard resurrect the 200 year old classic but with your own twist. Your friends decide the 5 letter version is too easy, so decide to convert it to a 7 letter variant.

In this variant, the aim of the game remains unchanged: the player attempts to find a word in a limited number of guesses. After a guess is made, the 7 letters are colored by the following rules:

  • If the letter doesn't appear in the solution, color it black (B);
  • If the letter does appear in the solution, but is in the wrong position, color it yellow (Y);
  • If the letter does appear in the solution, and is in the correct position, color it green (G).

A word is valid if it matches the responses of all guesses.

Your friends think that by using 7 letter words it will be too hard for you to solve, however they didn't count on you bringing your computer science skills to the table! You source a list of 7 letter words (your input data) and decide to create a program that will test guesses against it to find the answer.

An example

Three guesses were made that produced the following color coded responses:

hapless GBYYYBB
jackpot BBBBYBB
fullest YYGYYBB
  • The result from the guess hapless informs you that the final word starts with the letter h and also contains the letters p, l and e. The letters a, and s do not appear in the final word.
  • The result from the guess jackpot informs you that the final word contains the letter p, which we already knew so it wasn't a lot of help, except that we can also rule out the letters j, a, c, k, o, and t.
  • The result from the guess fullest informs you that the final word contains the letter l in the 3rd position, and also contains the letters f, u, l and e. The letters s and t are not in the final word.

By process of elimination, the only word that matches this in the input data is helpful, so that would be the answer.

Your question

The input data contains your word list. Find the only word that matches the following guesses: That is your answer.

keyless YYBBYYG
society YGYYYBB
phobias BBGBGBG

Wordle adaption by Edward Zhang and Paul Baumgarten.

Input data word list derived from github.com/dwyl/english-words.

Input data

Get your puzzle input data

What is the solution?

 

Hint

A video walkthrough for learning how to solve this problem is available here.