Plant Infection Simulation, Part 4: Death Countdown
Reported by candidates from OpenAI's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Brute force is the trap in this OpenAI OA, reported in October 2026. The grid is small in the example, but the real input isn't, and a simulation that rescans or rebuilds state badly will blow up over many days. This is Part 4 of the plant infection series, so you've likely seen the earlier parts. Now there's a death countdown layered on infection, recovery, and immune cells. It's a grid simulation with eight-neighbor counting. If you blank on the rule ordering, StealthCoder is the invisible safety net running during the live OA.
The problem
This part adds a death countdown to the infection-and-recovery simulation. Each input cell is X (infected),. (healthy), or I (immune). Immune cells never become infected and never transmit infection. Dead cells are terminal and never transmit infection. Daily Update Rules At the start of each day, count infected cells among each cell's eight horizontal, vertical, and diagonal neighbors. Using that start-of-day state: Examples Example 1 grid = ["X."] infectionThreshold = 2 duration = 1 deathThreshold = 1 return = [2, 1] On day 1, the healthy cell has one infected neighbor, so it starts a death countdown but does not meet the infection threshold. The initial infection recovers. The countdown finishes at the end of day 2, producing one death.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The pattern is simulation on a matrix. The trick is the start-of-day snapshot. Count infected neighbors from the old grid, then write every change into a new grid or a pending list. Never mutate in place, or one cell's update leaks into its neighbor's count the same day. Track per-cell state: healthy, infected with days remaining, countdown timer, immune, dead. Immune and dead cells never transmit, so skip them when counting. The common pitfall is the example itself. A cell can start a countdown without meeting the infection threshold, and the countdown keeps running after the source recovers. Missing that gives the wrong death count. Keep the eight-direction offsets in one array and bounds-check each one. The problem text is truncated, so read the exact update rules on screen before coding. If the ordering of rules gets tangled mid-OA, StealthCoder can give you a clean reference solution to check against.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill Plant Infection Simulation, Part 4: Death Countdown cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass OpenAI's OA.
OpenAI reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Plant Infection Simulation, Part 4: Death Countdown FAQ
How hard is the Plant Infection Simulation Part 4 really?+
The algorithm is easy. Eight-neighbor counting and a daily loop. The difficulty is state bookkeeping. Infection, recovery, countdown, and death all interact, and one wrong rule ordering breaks the output. Expect it to be a careful-reading problem, not a clever-trick problem.
What's the main trick?+
Use the start-of-day snapshot. Compute all neighbor counts from the old state, then apply every transition to a fresh grid. In-place updates corrupt counts mid-day. Store per-cell timers for recovery and death countdown so each day is one pass over the grid.
Why does the example produce a death with no infection?+
The healthy cell next to an infected one starts a death countdown even though it never hits the infection threshold. The original infection recovers after one day, but the countdown continues and finishes on day 2. That gives one death and the return value [2, 1].
How do immune and dead cells behave?+
Immune cells never get infected and never transmit. Dead cells are terminal and never transmit. When counting infected neighbors, only cells currently infected count. Treat immune and dead as skipped states in both the counting step and the transition step.
How do I prepare for this in 48 hours?+
Write a clean grid simulation from scratch. Use a directions array, a copied grid per step, and bounds checks. Then practice adding one rule at a time with timers per cell. Since this is Part 4, rehearse layering new rules without rewriting the earlier ones.