30/32
Part 7 of 7 · Follow-upsLearn and do

What tests would you write? The edges, a grid that isn't square, and the same grid flipped

  • A 1 by 1 grid.
  • A grid of only walls.
  • A cell walled off: -1.
  • Everything already done: 0.
  • k above 4.
  • A grid that isn't square. It catches swapped rows and columns.
  • The same grid flipped. It catches an in-place update.

The last test on that list turns the grid around. In the editor, write turn(grid), which turns a grid 180 degrees, and same_when_turned(minutes, grid, k), which checks that a minutes function gives the same answer both ways.

What about the practice problem's fifth part? Say the R + C bound first

Burn one whole row or column to stop the spread, and choose the one that leaves the fewest dead. There are R+CR + C choices, each a full simulation, so it costs R+CR + C times one simulation. Say that bound first, then look for ways to skip choices.