Sunday Times Teaser 3173 – Dots and Boxes
by Susan Bricket
Published Sunday July 16 2023 (link)

In this game, two players take turns drawing a single horizontal or vertical line between two unjoined adjacent dots in a rectangular grid. A player who completes the fourth side of a 1×1 box earns one point and takes another turn. The winner is the one with the most points at the end. A recent game with 4×4 dots (as above) between two beginners, reached a critical position when no box had more than two sides already drawn and the next player was forced to complete the third side of some box. It turned out that this was the shortest possible 4×4 game to reach a critical position. Their next 4×4 game reached a critical position in the largest possible number of turns.
How many turns were in each game?
Here is my first effort which is a bit slow:
A recursive solution is faster: