In the game
Wordle , there is a grid of 6 rows of 5 columns. You have 6 attempts to guess the secret 5-letter word. As you type a word, it appears in the next unfilled row. Once entered, the background color of each letter becomes either black (if that letter is not in the secret word), yellow (if the letter is in the secret word, but not in that position), or green (if the letter is in the word and in that same position).
If your guess word contains multiples of the same letter, the color rules are slightly different. For example if you guess SHEET and one E becomes green and the other black, then there is only one E in the secret word and you found it. But if one E becomes green and the other yellow, then there are (at least) 2 copies of the letter E, but not in the yellow location. If one is yellow and one is black, you know there is exactly one E but not in either of your guessed locations.
In Hard Mode, once you have found a green letter, subsequent guesses must use that letter in that position. Similarly yellow letters must be used in each subsequent guess though not necessarily in the same location.
At the conclusion of the game, the background color of each square in the 6 by 5 grid is either black, yellow, green, or clear for any unused guesses.
For Wordle Hard Mode, considering only the background colors, how many color patterns are possible once the game is over?
Break down your answer into groups of games won in 1 guess, in 2 guesses, ... , in 6 guesses, and finally games lost (in which the 6th guess was still not the secret word).
clearvars
combs=double.empty(0,3);
for g=0:5
for y=0:5-g
b=5-y-g;
combs(end+1,:)=[g y b];
end
end
win=[5,0,0];
count=zeros(1,7); count(1)=1;
trans=zeros(length(combs));
f5=factorial(5);
for a=1:length(combs) % produce transition matrix
l1=combs(a,:); % along with starting row possibilities
startNo(a)=f5/(factorial(l1(1))*factorial(l1(2))*factorial(l1(3)));
for b=1:length(combs)
if b==21
xx=99;
end
l2=combs(b,:);
if l2(1)>=l1(1) && sum(l2(1:2))>=sum(l1(1:2))
f=factorial( l2(1)-l1(1)+sum(l2(2:3)));
trans(a,b)=f/(factorial(l2(1)-l1(1))*factorial(l2(2))*factorial(l2(3)));
end
end
end
startNo(20)=0;
states=startNo;
for turn=2:6
states=states*trans;
states(20)=0; % impossible state: 4 green, 1 yellow
count(turn)=states(21);
states(21)=0; % once finished, it's out of the counting
end
count(7)=sum(states);
fprintf('%15d
',count)
disp(' ')
This program finds the numbers of patterns for win on guesses 1 through 6, and for complete failure:
1
238
12483
352009
7141380
119136806
1753981922
It does so by first listing all the possible configurations:
G Y B number of ways
in first row
(StartNo vector)
0 0 5 1
0 1 4 5
0 2 3 10
0 3 2 10
0 4 1 5
0 5 0 1
1 0 4 5
1 1 3 20
1 2 2 30
1 3 1 20
1 4 0 5
2 0 3 10
2 1 2 30
2 2 1 30
2 3 0 10
3 0 2 10
3 1 1 20
3 2 0 10
4 0 1 5
4 1 0 0
5 0 0 1
and the transition matrix from a numbered state to the next based on ways of permuting given the constraints:
1 5 10 10 5 1 5 20 30 20 5 10 30 30 10 10 20 10 5 5 1
0 5 10 10 5 1 5 20 30 20 5 10 30 30 10 10 20 10 5 5 1
0 0 10 10 5 1 0 20 30 20 5 10 30 30 10 10 20 10 5 5 1
0 0 0 10 5 1 0 0 30 20 5 0 30 30 10 10 20 10 5 5 1
0 0 0 0 5 1 0 0 0 20 5 0 0 30 10 0 20 10 5 5 1
0 0 0 0 0 1 0 0 0 0 5 0 0 0 10 0 0 10 0 5 1
0 0 0 0 0 0 1 4 6 4 1 4 12 12 4 6 12 6 4 4 1
0 0 0 0 0 0 0 4 6 4 1 4 12 12 4 6 12 6 4 4 1
0 0 0 0 0 0 0 0 6 4 1 0 12 12 4 6 12 6 4 4 1
0 0 0 0 0 0 0 0 0 4 1 0 0 12 4 0 12 6 4 4 1
0 0 0 0 0 0 0 0 0 0 1 0 0 0 4 0 0 6 0 4 1
0 0 0 0 0 0 0 0 0 0 0 1 3 3 1 3 6 3 3 3 1
0 0 0 0 0 0 0 0 0 0 0 0 3 3 1 3 6 3 3 3 1
0 0 0 0 0 0 0 0 0 0 0 0 0 3 1 0 6 3 3 3 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 3 0 3 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 2 2 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 2 2 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 2 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
Edited on February 26, 2025, 7:52 am
|
Posted by Charlie
on 2025-02-26 07:49:41 |