← blog  /  tools

Fill-in puzzle generator in Python: why one word starts in place

2026-11-19  ·  5 min read  ·  tools

We built 500 fill-in grids from 60 Christmas themes. Without a word printed in place, 22 to 29 % could be filled in two ways, with HOPE and LOVE trading places. One starting word fixes almost all of them.

A fill-in puzzle, also called a fill-it or criss-cross puzzle, is a crossword without clues: an empty grid and the list of its words, grouped by length. The solver fits every word in so that crossing words share their letters. A generator has to give the solver a grid that fills in only one way.

The grids here come from best_grid() in our crossword generator post. On 31 October 2026 we counted the ways to fill them, on the 60 Christmas and winter themes of our puzzle books (1,425 words).

The short version#

  • No starting word: easy grids (words of 3 to 7 letters, 14 drawn) filled in one way in 78 % of 300; medium grids (3 to 10 letters, 20 drawn) in 71 % of 200. The rest had two ways. Typically two words of the same length traded places where they cross matching letters: HOPE and LOVE, GOOSE and ROAST, DONNER and HOOVES.
  • One word printed in place: for 97 % of easy and 94 % of medium grids, some word made the grid fill in one way. On average 81 % of the words in an easy grid would work as the start, and 73 % in a medium one.
  • The generator: try each word as the starting one, and draw a new grid when none works. That took 1.03 grids a puzzle on average, about 10 ms.

The code#

Count the ways a fill-in grid can be filled, and pick a starting wordpython
import random
from crossword import best_grid, show   # from our crossword generator post


def fillings(placed, given=None, stop=2):
    """The ways the listed words fit the empty grid (up to `stop` of them): every word once, crossing squares agree.
    `placed` is [(word, row, col, direction)]; `given` is the index of the word printed in place to start."""
    words = [w for w, r, c, d in placed]
    cells = [[(r + d[0] * i, c + d[1] * i) for i in range(len(w))] for w, r, c, d in placed]
    grid, filled, used, found = {}, {}, set(), []

    def put(k, w):
        new = [cell for cell in cells[k] if cell not in grid]
        for cell, ch in zip(cells[k], w):
            grid[cell] = ch
        filled[k] = w
        used.add(w)
        return new

    def take(k, new):
        used.discard(filled.pop(k))
        for cell in new:
            del grid[cell]

    def go():
        if len(found) >= stop:
            return
        if len(filled) == len(words):
            found.append(dict(filled))
            return
        options = {k: [w for w in words if w not in used and len(w) == len(cells[k])
                       and all(grid.get(cell, ch) == ch for cell, ch in zip(cells[k], w))]
                   for k in range(len(words)) if k not in filled}
        k = min(options, key=lambda x: len(options[x]))        # the slot with the fewest words that fit
        for w in options[k]:
            new = put(k, w)
            go()
            take(k, new)

    if given is not None:
        put(given, words[given])
    go()
    return found


def make(theme_words, count=14, shortest=3, longest=7, rng=random, tries=100):
    """A grid and a starting word with which it fills in exactly one way: draw words from the theme, build the
    grid, try each word as the starting one; if none works, draw again."""
    pool = [w for w in theme_words if shortest <= len(w) <= longest]
    for k in range(1, tries + 1):
        grid, placed = best_grid(rng.sample(pool, min(count, len(pool))), rng=rng)
        for given in rng.sample(range(len(placed)), len(placed)):
            if len(fillings(placed, given)) == 1:
                return grid, placed, given, k
    raise RuntimeError("no grid that fills in one way")
Run itpython
grid, placed, given, draws = make(themes["Trimming the Tree"], rng=random.Random(2))
print(show(grid))
print("words:", len(placed), "| starting word:", placed[given][0], "| ways:", len(fillings(placed, given)),
      "| without it:", len(fillings(placed)))

With that seed it built this grid of 14 words and picked SPARKLE to start:

The finished gridtext
. . . . . . . . . . . B
. . B . . S T A R . . E
. . A . . P . . . . . A
. . U . . R . . . P . D
. . B . . U . H O O K S
A . L . . C . . . P . .
N E E D L E S . . C . .
G . . . . . P . . O . .
E . . . . . A . . R . .
L . . . G A R L A N D .
. . . . . . K . . . . .
. . . L . . L . . . . .
. I C I C L E S . . . .
. . . G . . . T . . . .
. . . H . . . R . . . .
. . . T . . . I . . . .
T I N S E L . N . . . .
. . . . . . . G . . . .

This one would fill in one way even without SPARKLE. About one easy grid in five would not.

Why one word is enough#

HOPE and LOVE can trade places only where the grid asks for the same letters from both: the O and the E. Print either of them in place, or a word that crosses one of them at the H, P, L or V, and the swap is gone. fillings() checks this directly: it places the starting word first and then counts every way to place the rest, up to two.

Where two ways were left, they differed in two words in the median case, and in four at most. So the second way is usually one swap, which a solver finds by accident and the answer key calls wrong.

Counting is cheap at this size, because fillings() always fills the slot with the fewest words that still fit. All the checks for one grid, with no starting word and then each word in turn, took 8 ms (median) for an easy grid and 23 ms for a medium one.

A whole book, not one grid#

Our fill in book maker checks every puzzle the same way: a second program, written apart from the one that makes the puzzles, tries every way to fit the listed words into the empty grid, starting from the word already in place, and finds exactly one. Every run of two or more boxes is a word from the list, each word is in the grid once, the grid is one connected piece, and no word touches another side by side.

Easy books use words of 3 to 7 letters, up to 14 a puzzle; medium 3 to 10 letters, up to 20; hard 3 to 12 letters, up to 26. You can use our 60 Christmas and winter themes and 103 everyday ones, and the book is checked against KDP's paperback specs before you can download it. One fill in book costs 500 credits, from $3.30 in the big pack.

written