Model Infection, Immunity, Delayed Death, and Burn Interventions on a Grid
Company: OpenAI
Role: Machine Learning Engineer
Category: Software Engineering Fundamentals
Difficulty: medium
Interview Round: Technical Screen
Design and reason about a grid-based plant-infection simulation that grows through five stages: infection spread, immune cells, expiring immunity, delayed death, and a row-or-column burn intervention.
This is a conceptual modeling and algorithm discussion. The transition rules listed below are intentionally incomplete. Identify the missing rules, explain how each choice affects the result, and describe an implementation approach once those rules are agreed. Do not claim a numerical answer or a uniquely specified executable simulation without that agreement.
### Shared Constraints and Clarifications
The input is a grid of cells. Clarify which cells are neighbors, how infection spreads, whether updates happen simultaneously or in place, how boundaries behave, and what counts as a day. Distinguish a stable state from a state in which every eligible plant is infected. For later stages, the complete state includes countdowns as well as visible cell types.
### Part 1 — Find the Time to Stabilization
Initially, cells are healthy or infected. Explain how to determine how many days pass before the grid stabilizes.
#### What This Part Should Cover
- The missing infection and update rules needed to define a day's transition.
- A precise stabilization test and a convention for a grid that is stable initially.
- When a layered spread algorithm is valid and when a general simulation is required.
### Part 2 — Add Immune Cells
Introduce an immune-cell state and determine when infection is complete, if it can become complete.
#### What This Part Should Cover
- Whether immune cells block transmission, remain uninfectable, or have another defined effect.
- Whether "complete" includes immune cells or only cells eligible for infection.
- A distinction between successful completion and stabilization with unreachable healthy cells.
### Part 3 — Add an Immunity Countdown
Give immune cells a countdown. Explain how to model its expiration and its effect on the time to infection or stabilization.
#### What This Part Should Cover
- The countdown's initial value, decrement timing, and the state reached on expiration.
- The order of expiration and infection processing on the same day.
- A stopping rule that does not mistake an unchanged visible grid for a stable simulation while timers are still active.
### Part 4 — Add an Infected-Neighbor Death Trigger
When a cell has a specified number of infected neighbors, it enters a death countdown. Explain how this changes the state representation and simulation.
#### What This Part Should Cover
- The threshold, eligible cell types, and whether a started countdown continues if the neighbor count later falls.
- Whether a dying cell can transmit infection and what happens when the countdown reaches zero.
- Rule precedence when infection, immunity expiration, and death-related events coincide.
### Part 5 — Choose a Burn Intervention
Choose one row to burn, one column to burn, or no burn, with the objective of reducing the total number of deaths.
#### What This Part Should Cover
- Burn timing, the resulting state of burned cells, and whether those cells count toward total deaths.
- A fair comparison of all allowed interventions from the same initial state under the agreed transition rules.
- The no-burn baseline, ties between interventions, and the cost of repeated simulation.
```hint Countdowns are part of the state
Two grids with the same visible cell labels can have different futures if their immunity or death countdowns differ. Include that hidden progress when deciding whether anything can still happen.
```
```hint Compare interventions on independent copies
A row-burn experiment must not change the initial grid used by a column-burn experiment. The comparison also needs one consistent definition of a death.
```
### What a Strong Answer Covers
Each stage has an explicit state and transition contract before an algorithm is chosen. The explanation separates stabilization, complete infection, and death minimization; preserves time-step semantics; detects unreachable or nonterminating cases when relevant; and evaluates burn actions without silently changing the objective or rules.
### Follow-up Questions
1. Why can processing cells in place produce a different stabilization time from simultaneous daily updates?
2. How could an immunity countdown expire on a day when the visible grid had appeared unchanged for several days?
3. Under what additional assumptions could the first stage use a multi-source breadth-first traversal, and why might that optimization fail after death countdowns are added?
4. How would the optimal burn choice change if burned plants counted as deaths rather than being excluded from the objective?
Overview: Model a five-stage plant-infection simulation with immunity, countdowns, delayed death, and row-or-column burning while clarifying transition rules.
Design and reason about a grid-based plant-infection simulation that grows through five stages: infection spread, immune cells, expiring immunity, delayed death, and a row-or-column burn intervention.
This is a conceptual modeling and algorithm discussion. The transition rules listed below are intentionally incomplete. Identify the missing rules, explain how each choice affects the result, and describe an implementation approach once those rules are agreed. Do not claim a numerical answer or a uniquely specified executable simulation without that agreement.
Shared Constraints and Clarifications
The input is a grid of cells. Clarify which cells are neighbors, how infection spreads, whether updates happen simultaneously or in place, how boundaries behave, and what counts as a day. Distinguish a stable state from a state in which every eligible plant is infected. For later stages, the complete state includes countdowns as well as visible cell types.
Part 1 — Find the Time to Stabilization
Initially, cells are healthy or infected. Explain how to determine how many days pass before the grid stabilizes.
What This Part Should Cover Guidance
The missing infection and update rules needed to define a day's transition.
A precise stabilization test and a convention for a grid that is stable initially.
When a layered spread algorithm is valid and when a general simulation is required.
Part 2 — Add Immune Cells
Introduce an immune-cell state and determine when infection is complete, if it can become complete.
What This Part Should Cover Guidance
Whether immune cells block transmission, remain uninfectable, or have another defined effect.
Whether "complete" includes immune cells or only cells eligible for infection.
A distinction between successful completion and stabilization with unreachable healthy cells.
Part 3 — Add an Immunity Countdown
Give immune cells a countdown. Explain how to model its expiration and its effect on the time to infection or stabilization.
What This Part Should Cover Guidance
The countdown's initial value, decrement timing, and the state reached on expiration.
The order of expiration and infection processing on the same day.
A stopping rule that does not mistake an unchanged visible grid for a stable simulation while timers are still active.
Part 4 — Add an Infected-Neighbor Death Trigger
When a cell has a specified number of infected neighbors, it enters a death countdown. Explain how this changes the state representation and simulation.
What This Part Should Cover Guidance
The threshold, eligible cell types, and whether a started countdown continues if the neighbor count later falls.
Whether a dying cell can transmit infection and what happens when the countdown reaches zero.
Rule precedence when infection, immunity expiration, and death-related events coincide.
Part 5 — Choose a Burn Intervention
Choose one row to burn, one column to burn, or no burn, with the objective of reducing the total number of deaths.
What This Part Should Cover Guidance
Burn timing, the resulting state of burned cells, and whether those cells count toward total deaths.
A fair comparison of all allowed interventions from the same initial state under the agreed transition rules.
The no-burn baseline, ties between interventions, and the cost of repeated simulation.
What a Strong Answer Covers Guidance
Each stage has an explicit state and transition contract before an algorithm is chosen. The explanation separates stabilization, complete infection, and death minimization; preserves time-step semantics; detects unreachable or nonterminating cases when relevant; and evaluates burn actions without silently changing the objective or rules.
Follow-up Questions Guidance
Why can processing cells in place produce a different stabilization time from simultaneous daily updates?
How could an immunity countdown expire on a day when the visible grid had appeared unchanged for several days?
Under what additional assumptions could the first stage use a multi-source breadth-first traversal, and why might that optimization fail after death countdowns are added?
How would the optimal burn choice change if burned plants counted as deaths rather than being excluded from the objective?