Advertisement
Telegram ads for your business · TCA Media
Advertisement
Telegram ads for your business · TCA Media
IT

I used to spend an hour every day on one puzzle. Now it generates itself in under a second

The creator of the daily game 'Threads' has developed a puzzle generator: previously, each one took an hour to create, but now an individual puzzle is generated in under a second.

25 Nov, 19:00Read in Russian
habr.com

In 'Threads,' players must find words on a common theme within a 6 × 8 letter grid. Words follow adjacent cells, including diagonals, and must cover the entire grid without overlaps.

Initially, the author assembled such tasks manually. The generator proved more challenging: it either produced dull themes like 'birds' or incorrect grids where the required word could accidentally be read via an alternative path, causing the system to reject the correct answer.

For automated generation, the author retained three types of themes: a short word hidden within others; words with different meanings; and stable phrases with a single adjective. The generator constructs the layout using backtracking and checks whether any words form a second path. This verification must be performed during grid assembly.

The author compared several approaches. His search algorithm assembled puzzles in 23 out of 78 runs on complex themes, while Google OR-Tools failed to solve any of the 13 tested themes within the allotted time. Ultimately, the problem was resolved not by a more complex algorithm but by modifying the rule for checking extraneous theme words.

Advertisement
Telegram ads for your business · TCA Media