# Reference patch — 03-nearest-spot

The answer key for how the reference absorbs this change, and the thing that makes
`budget.json` reproducible. **Never shipped to the candidate.**

1. **Overlay** `../contract-delta/ParkingLotApi.java` onto `contract/ParkingLotApi.java`. Contract
   files are given, so nothing here is charged.
2. **Add four lines** to `reference/src/ParkingLot.java`, immediately above the private
   `noRoomFor` helper:

   ```java
   @Override
   public String nextSpotFor(VehicleType type) {
       return allocator.allocate(type, grid).orElseThrow(() -> noRoomFor(type)).get(0);
   }
   ```

No new file, and **no change to the allocator**: `FirstFitAllocator` already scans
`grid.spotIds()` from the lowest-numbered spot upward, so "always the nearest free spot" was
already true. That is the whole point of this curveball — it looks like an algorithm change and is
actually an API addition, and a design that kept its free spots in a stack or a `HashSet` pays for
the difference here.

The method is a one-liner only because `SpotAllocator.allocate` is pure: it decides without
touching the grid, so the lot can ask the question without parking anything.

Measured: `reference_diff = 4` (4 added, 0 removed, one file touched), so
`diff_budget = max(3, 4 + ceil(4/2)) = 6`.

Both the curveball suite (6 tests) and the base suite (10 tests) are green after the patch.
