We can’t use a char[] pattern because of limitations in the char type for tiles. Your tiles must be stored as strings!
If you want to run the code in jGRASP for debugging purposes, the tiles may or may not display correctly. In this case, you may want to temporarily change the strings to other characters so that it’s easier to read.
record(String guess)
For each call to record, construct a Map to associate patterns with target word sets and use it to find all pick the pattern associated with the largest number of target words. When there are multiple patterns that have the same largest number of target words, pick the pattern that appears first in the sorted order, i.e. the pattern that appears earliest when iterating over the TreeMap. The associated target words becomes the dictionary for the next call to record.
It’s necessary to construct a new Map on each call to record because the patterns depend on the given guess!
Development strategy
Implement the constructor and the words method first. Then, implement and test the patternFor static method. If your patternFor method is not working, your record method also will not work!
AbsurdleMain has two constants that you will want to change:
DICTIONARY_FILE represents the name of the file containing the list of initial words. By default, it reads from dictionary1.txt, which contains the official list of 2309 5-letter words used in Wordle. When testing, it may be easier to use the dictionary2.txt file that only contains 9 4-letter words.
SHOW_COUNT is false by default; set it to true to see the number of words under consideration.
———————————————
import java.util.*;
public class AbsurdleManager {
// TODO: Your Code Here
// The comment for this method is provided. Do not modify this comment:
// Params:
// String word — the secret word trying to be guessed. Assumes word is made up of only
// lower case letters and is the same length as guess.
// String guess — the guess for the word. Assumes guess is made up of only
// lower case letters and is the same length as word.
// Exceptions:
// none
// Returns:
// returns a string, made up of gray, yellow, or green squares, representing a
// standard wordle clue for the provided guess made against the provided secret word.
public static String patternFor(String word, String guess) {
}
}
Enjoy 24/7 customer support for any queries or concerns you have.
Phone: +1 213 3772458
Email: support@gradeessays.com