# Reference patch — 01-a-new-coin

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/Coin.java` onto `contract/Coin.java`. Contract files are given,
   so nothing here is charged.
2. **Change nothing else.** There is no patch. `reference/src` is byte-identical before and after.

```
$ node workspace/_vm_measure.mjs 01-a-new-coin
{ "reference_diff": 0, "diff_budget": 3, "touchedFiles": 0, "newFiles": 0, "perFile": {} }
```

Measured: `reference_diff = 0`, so `diff_budget = max(3, 0 + ceil(0/2)) = 3` — the floor.

Both suites are green after the overlay: the curveball suite (6 tests) and the base suite
(16 tests). The base suite staying green is part of the requirement — the float is deliberately
*not* pre-loaded with half-dollars, so a machine that has not seen one still refuses exactly the
sales it refused before.

## Why it costs nothing

Three places could have known how many denominations there are, and none of them does:

| Place | What it does instead of naming coins |
|---|---|
| `GreedyChangeMaker` | `Arrays.stream(Coin.values()).sorted(by minorValue, reversed)` — the set *and* the order are derived, not written down |
| `CoinPurse` | `new EnumMap<>(Coin.class)`, `getOrDefault(coin, 0)` — an unmentioned coin is a count of zero |
| `MachineFactory.standardFloat()` | `Map.of(NICKEL, 1, DIME, 2, QUARTER, 1)` — a partial map, so a new coin needs no entry |

**What this curveball is really testing.** It looks like the easiest of the three and it is the
most discriminating, because the plausible wrong answers are all cheap-looking:

- `switch (coin)` anywhere — in a value lookup, in change-making, in the float — stops compiling
  or silently mis-prices. Each site is an edit.
- `int[] counts = new int[4]` or `new int[]{100, 25, 10, 5}` — one array literal per site.
- Relying on `Coin.values()` being in ascending declaration order and iterating it backwards
  works here *by luck*, because the delta inserts the new constant in the right place. A design
  that sorts explicitly is not relying on luck, and that difference is worth naming out loud in
  the defence even though the suite cannot distinguish them.
- A float declared as a full map with an entry per denomination — one line, but the wrong line,
  because it makes the float a list that has to be maintained rather than a set of exceptions to
  zero.
