Your question is Simulate Infection Propagation. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
OpenAI Codex is evaluating a plant-health simulation represented as a rectangular grid. Implement a synchronous daily simulation that propagates infection while modeling recovery, temporary immunity, and mortality.
Each cell is one of four strings: "S" for susceptible, "I" for infected, "R" for temporarily immune after recovery, or "D" for dead. Only orthogonal neighbors count. Every cell is evaluated from the state at the start of the day, so updates must not affect other cells during that same day. All initially infected cells have infection age zero.
For each day:
infection_threshold infected neighbors.mortality_threshold infected neighbors. Otherwise, its infection age increases. It recovers when its new age reaches recovery_days.immunity_days, then becomes susceptible.Return the grid after exactly days days.
Implement simulate_infection(grid, days, infection_threshold, recovery_days, immunity_days, mortality_threshold). grid is a non-empty M x N matrix of strings, and the result has the same dimensions. The input grid must not be modified.
def simulate_infection(grid, days, infection_threshold, recovery_days, immunity_days, mortality_threshold):