Grid Infection and Immunity Simulation

Asked at OpenAI · Coding Questions · Difficulty: Hard · Last asked Jun 29, 2026

A rectangular field is divided into cells. Each day, healthy cells next to enough infected cells become infected, infected cells count down to recovery, and recovered cells stay immune for good. Implement the daily update, then the answers that need many days at once: the state after `T` days and the day on which the field stops changing, even for very large grids and `T` up to `10^9`.

Loading the problem…