19/32
Part 5 of 7 · RoundsLearn and do

Read the old grid and write a new one, so all of a minute's changes land at once

So you simulate: work out each round's grid from the one before. One rule keeps it right. Every cell reads the grid as it was at the start of the round, and every change lands at once. Read from the old grid and write into a new one:

def spread_once(grid, k=1):
    # write here
    new = [list(row) for row in grid]
    # read here
    for r, row in enumerate(grid):
        for c, state in enumerate(row):
            if state == ".":
                burning = sum(grid[nr][nc] == "F" for nr, nc in open_neighbors(grid, r, c))
                if burning >= k:
                    new[r][c] = "F"
    return ["".join(row) for row in new]


def minutes_by_rescan(grid, k=1):
    minutes = 0
    while True:
        new = spread_once(grid, k)
        # a round that changes nothing ends it
        if new == grid:
            break
        grid, minutes = new, minutes + 1
    return -1 if any("." in row for row in grid) else minutes

Strings can't be changed in place, so [list(row) for row in grid] makes each row a list of characters, and "".join(row) turns it back into a string. The sum counts the burning neighbors: each comparison is True or False, and True adds as 1. On the k = 2 forest above, minutes_by_rescan returns 4.

Here's what the new grid buys, on the one-row forest F.... with k = 1:

F.... with k = 1, two ways
a new grid each minute
minute 1FF...minute 2FFF..minute 3FFFF.minute 4FFFFF
written in place
minute 1FFFFF

Scanning left to right in place, each new fire lights the next tree in the same minute. Red trees caught too soon.

In the editor is spread_once with one wrong read, and it lights the whole row F.... in one minute. Find it and fix it.