Wordle 3: analysing the effectiveness of the solver

First, set the browser to Full Screen view, to give this worksheet and your code as much space as possible.

Then choose either one of the two options below:

Option 1: Start this worksheet from scratch

Option 2: Continue, or view, previous work

This worksheet is copyright © Richard Pawson 2025, and protected by the Creative Commons license: Attribution-NonCommercial-NoDerivatives 4.0 International. You may freely make and distribute copies of this worksheet as is, but if you modify this worksheet you may not distribute your modified version (outside your own teaching institution) without the author's permission. Please email the author to report errors or suggest improvements.

Step 1: introduction

Following-on from 'Wordle 2: writing an automated solver', in this worksheet your challenge is to write an analyser that can evaluate:

  1. Just how effective that automated solver is at solving puzzles, by getting it attempt to solve all 2,315 of the valid target words, and measuring the percentage that it solves within six attempts. For those successful cases, it should also calculate the average number of attempts required.
  2. Whether ARISE is the best starting word for that algorithm or, if not, what is the best starting word.

and then immediately file > auto save the code to your local file storage, because you will be making changes and want to ensure that your changes are saved.

Notice the following:

Notes

Total hints used: /

Step 2: implement 'attemptsNeededToSolve'

Hint 2-1: implementation in outline form
Hint 2-2: complete implementation

When your implementation of attemptsNeededToSolve is complete, all the test-cases (asserts) in test attemptsNeededToSolve should pass.

Notes

Total hints used: /

Step 3: write a main to use the new function

Write a main routine that:

Hint 3-1: outline instructions
Hint 3-2: the input and output
Hint 3-3: complete main routine

When you have this implemented, run the program to find out how many attempts it takes to identify the target words CHURN and then FIZZY.

Record your results here:

Notes

Total hints used: /

Step 4: analyse the algorithm for all potential target words

In order to identify the effectiveness of a Wordle solver we need to test it against all 2,315 valid target words, and from this determine the percentage of of the puzzles it was able to solve in 6 or fewer attempts, and, for those successes, the average number of attempts needed.

Notes

Total hints used: /

Step 5: Calculate the number of successful solutions

Now we will calculate success the total number of puzzles that the algorithm solves within 6 attempts.

Add a loop that evaluates the number of attempts to solve each of the targetwords provided in validTargets, and if that number is within the limit of six, increment the value of success by one.

Hint 5-1: the new code in outline
Hint 5-2: the complete function so far

Although none of the asserts in the new test will be passing yet, what do you notice about the two values that are being generated by the function in the test?

Notes

Total hints used: /

Step 6: Calculate the weighted-sum of the number of attempts

Now we will calculate the weightedSum of the number of successful attempts, from which the average is subsequently derived.

Hint 6-1: the array definition
Hint 6-2: how to update the array
Hint 6-3: the new loop in outline
Hint 6-4: the completed instruction for updating 'outcomes'
Hint 6-5: the completed function

When implemented, all the asserts in the test analyseAlgorithm should be passing.

Notes

Total hints used: /

Step 7: Re-write main to present the results of the analysis

Your task is now to re-write main to understake the analysis and present the results.

Hint 7-1: expression to split the target words into a list
Hint 7-2: deconstructing the tuple returned by analyseAlgorithm
Hint 7-3: how to create the formatted output
Hint 7-4: the completed 'main'

Run the program

Record the results (% solved and the average number of attempts) here:

Finally, try changing ARISE to an alternative first attempt word. Maybe try a few likely candidates.

Record the result from the best first attempt word that you found, whether or not it was better than ARISE.

Notes

Total hints used: /

Congratulations! Worksheet completed

Hopefully you were impressed at the effectiveness of the algorithm that you wrote. It would likely beat many human players - over a reasonable run of puzzles!

You now have the option to

to explore the parts of the code that you haven't written such as the display logic.

If you would like to share the working application with others, click file > save as standalone to save it as a self-contained single web page that shows only an enlarged version of the display tab runs the program automatically when it is opened, and which runs automatically when opened. This standalone email file may be emailed to others. You might like to print a few more instructions within main and/or add any of the refinements below.

If you have time, there are plenty of ways that you could extend this investigation into Wordle, including: