Boss

Boss: The Glitch Gremlin

The boss
Boss Fight!
Every passing test breaks a shield.

The Glitch Gremlin has crept into the Guild's quest board and planted four bugs, one from each family you've met. The board crashes, quests share their tags, the purse says "too expensive" when it isn't, and saved snapshots change by themselves!

Use the detective method: read the clue, shrink the case, check your guess with a print or assert, then fix. Each of Pip's tests is named after one bug, so a red test tells you which family to hunt.

The bug reports

  1. The sticky default: every quest added without tags shares one tags list, so it fills up with "new", "new", "new"... Each quest must get its own list: given tags plus "new", even when two quests are given the same list (don't change the caller's list either).
  2. The vanishing list: top_quests(board, n) crashes with TypeError: 'NoneType' object is not subscriptable. It must return the titles of the n highest-reward quests, best first, without reordering board. (sorted() makes a new list; .sort() returns None.)
  3. The float trap: can_afford(0.3, [0.1, 0.2]) says False. It should be True when the prices add up to the wallet or less. Prices and wallets use coins with at most 2 decimal places. Allow for tiny float errors (try round(..., 2) or math.isclose).
  4. The shared backpack: after s = snapshot(board), changing a quest on the board also changes s. The snapshot must be a completely independent copy, all the way down.

Assignment

Fix all four bugs. Keep the function names and arguments the same.