Wordle 3: analysing the effectiveness of the solver
  1. Set the browser to Full Screen view, to give this worksheet and your code as much space as possible.
  2. to continue. (After that any entries made into the worksheet will be automatically saved, and you can re-load the partially-completed worksheet in future – at which point you will be asked to auto-save it again).
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 note the following:

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.

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:

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.

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?

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.

Total hints used: /

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

Your task is now to re-write main (start by deleting all the existing instructions within it) 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.

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!

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