Clutch Wordle Solver with known inputs
Sometimes when you're playing Wordle, you get to your fifth guess and you can't figure out the word any more, so you start mentally running through the list of remaining iterations, both sensical and nonsensical trying to figure out what those last few letters are.
The task here is to create all permutations of a final Wordle guess to save me from having to do it in my head, with the following rules:
General rule - since Wordle only uses valid English words, only letters that appear on a standard English keyboard (a-z) need to be tested.
Input:
- Green Guesses: Must accept a list of known letters and their position/s.
- Yellow Guesses: Must accept a list of known letters with positions they can not be (green guess positions can be excluded).
- Unguessed Letters: Must accept a list of remaining unguessed letters.
- (Optional) a way to indicate if a letter is known to appear only n times, excluding it from further consideration.
Note, green and yellow may still appear in more than the known positions.
Output:
- All possible outcomes must be presented (no need to import a dictionary).
- Solution set should be sorted alphabetically, A-Z.
To confirm the list, in each case you can multiply the possible letters for each slot by the number of possible letters in all of the other slots (slot 1 * slot 2 * slot 3 * slot 4 * slot 5).
What's the shortest way to solve this problem?
Example:
- Green Guesses: O=2, E=4, N=5
- Yellow Guesses: N!=3 (E!=5 is excluded because we know N=5)
- Unguessed Letters: Q, W, I, P, F, J, K, X, B
- null
Output would be a list of all possible permutations given the known information, such as:
B | E | F | I | J | K | N | O | P | Q | W | X |
---|---|---|---|---|---|---|---|---|---|---|---|
BOBEN | EOBEN | FOBEN | IOBEN | JOBEN | KOBEN | NOBEN | OOBEN | POBEN | QOBEN | WOBEN | XOBEN |
BOEEN | EOEEN | FOEEN | IOEEN | JOEEN | KOEEN | NOEEN | OOEEN | POEEN | QOEEN | WOEEN | XOEEN |
BOFEN | EOFEN | FOFEN | IOFEN | JOFEN | KOFEN | NOFEN | OOFEN | POFEN | QOFEN | WOFEN | XOFEN |
BOIEN | EOIEN | FOIEN | IOIEN | JOIEN | KOIEN | NOIEN | OOIEN | POIEN | QOIEN | WOIEN | XOIEN |
BOJEN | EOJEN | FOJEN | IOJEN | JOJEN | KOJEN | NOJEN | OOJEN | POJEN | QOJEN | WOJEN | XOJEN |
BOKEN | EOKEN | FOKEN | IOKEN | JOKEN | KOKEN | NOKEN | OOKEN | POKEN | QOKEN | WOKEN | XOKEN |
BOOEN | EOOEN | FOOEN | IOOEN | JOOEN | KOOEN | NOOEN | OOOEN | POOEN | QOOEN | WOOEN | XOOEN |
BOPEN | EOPEN | FOPEN | IOPEN | JOPEN | KOPEN | NOPEN | OOPEN | POPEN | QOPEN | WOPEN | XOPEN |
BOQEN | EOQEN | FOQEN | IOQEN | JOQEN | KOQEN | NOQEN | OOQEN | POQEN | QOQEN | WOQEN | XOQEN |
BOWEN | EOWEN | FOWEN | IOWEN | JOWEN | KOWEN | NOWEN | OOWEN | POWEN | QOWEN | WOWEN | XOWEN |
BOXEN | EOXEN | FOXEN | IOXEN | JOXEN | KOXEN | NOXEN | OOXEN | POXEN | QOXEN | WOXEN | XOXEN |
In this case, there are 12, 1, 11, 1, 1 potential outcomes for each slot, so the list should have 12*11 items or 132.