Code RoomSpatial hash boundary off-by-one
HardPrep Room Coding #4298

Spatial hash boundary off-by-one

Vibe & agenticAlgorithms & data structuresSenior–Staff~20 min

An AI agent wrote a spatial-hash broadphase for collision in C++. Most collisions work, but objects sometimes tunnel through each other when they sit exactly on a cell boundary, and large objects miss collisions with small ones at the edge of their span. Review the query and find the off-by-one.

Implement
spatial_cells_for_box(min_x: float, min_y: float, max_x: float, max_y: float, cell_size: float) → list[list[int]]
Examples
in[0.5,0.5,1.5,1.5,1]out[[0,0],[0,1],[1,0],[1,1]]
in[0.1,0.1,0.9,0.9,1]out[[0,0]]
in[1,1,2,2,1]out[[1,1],[1,2],[2,1],[2,2]]
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.

0:00 of about 20 min

Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.

Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.