CSC 2210, SPA 2: Wordle Assist

Description

Wordle is a popular word-guessing game hosted by NYTimes. The player attempts to find a 5-letter target word in 6 guesses or less. For each guess, the game shows the letter in green if it is in the correct position and yellow if it appears in the word but at a different location. If a letter appears more than once in a guess word, the number of times that letter appears as yellow or green depends on how often the letter appears in the target word. A new target word is picked every day, so players can compare their results on a daily basis. We highly recommend playing the game once to get a basic understanding.

A common strategy is to pick words that contain very frequent letters. For example, AISLE is good because it contains three most common vowels and two other common letters. But at some point the player has to switch to finding words that match the given clues. This is a large part of the game, and "AI" solutions do not have to be very intelligent because they can simply run through the list of possible answers, testing which work. If you could memorize the full word list, you too would play as well as a computer! The fun of the game is trying to recall words that fit.

As a player, I have a question: how often are my guesses really good ones? That is, how successful am I at finding intermediate words that narrow the choices quickly? A tool to evaluate guesses could also be useful to beginners. You are to write a program that computes the number of words that match a given word and displays those alternatives.

The program will read a list of 5-letter words, all in lower case. This list will be terminated by the word END (in upper case). This will be followed by up to 10 guesses (just to allow the player opportunities to explore further). For each guess there are two items: the first is the word (5 lower case letters) and the second is 5 characters indicating which of the guess letters match. In this second item, a period ('.') indicates a letter which matches the position, a dash ('-') indicates a complete miss, and a question mark ('?') indicates a letter that appears in the word but not at the given position. You will not implement the rule that if a letter appears more than once in a guess but only once in the target, only one of the two occurrences in the guess can be marked with '.' or '?'. The output will be a count of how many words can match and the list of the words that match. List the words in the same order they appear in the input.

This is an individual assignment. If you are having difficulties, it would be very good to talk to your instructor because there are likely logic issues that you need to discuss. Maybe we need to add more hints!

For example, if the input is

        anvil
        chard
        chase
        cross
        phase
        proud
        spade
        spate
        train
        END
        aisle
        ?-?-.
        choir
        -----
the the output will be
        Possible guesses after aisle, choir: 2
        spade
        spate

Design Requirements

Stage 1

The first test will have an empty set of words and empty set of guesses. You need just print

        Possible guesses after : 0
and exit. This means stage 1 is correct simply by writing can_match and ensuring it passes the above assertions. You can receive 40% of the points for this assignment by completing just this portion. Note there is a space between the word after and the colon - that is because there are no guesses and having a space there allows writing a simple loop printing all of the guesses.

Stage 2

Complete the rest of the lab. You will probably want to start by simply reading the input words and guesses, then writing a function to fill an array possible_answers (or some similar name) with all words and prints out that list, then refine the function to compute the possible answers by first checking each word is allowed by the first guess, and finally filter out all words that are not allowed by any of the guesses. But there are different implementation strategies; use whatever works for you.

Hints

This section gives further hints for portions of this assignment. You do not have to follow these hints, but they might save you some time.

Submitting

Common Issues