The One-Cent Book of Madness — JavaScript Bug Hunt

Inspired by the algorithmic pricing wars on marketplace sites — most famously the biology textbook priced at $23 million by two bots repricing against each…

  • Language: JavaScript
  • Layer: Backend
  • Difficulty: Medium
  • Concepts: Pricing, Feedback Loops
  • Modelled on: Amazon repricers
  • Visible tests: one round undercuts by a cent; long wars stop at the floors
  • Reward: 50 XP for a complete fix

Briefing

Inspired by the algorithmic pricing wars on marketplace sites — most famously the biology textbook priced at $23 million by two bots repricing against each other, and the mirror-image death spirals racing to one cent.

Two sellers undercut each other by a cent per round. Without a floor, they race to zero. repricer.js has no floor.

Bug report

BUG-23M · Priority: High · Reported by: marketplace integrity

battle(priceA, priceB, floorA, floorB, rounds):

  • each round: A = max(floorA, B - 1), then B = max(floorB, A - 1)
  • returns [finalA, finalB]

Observed: after a weekend of rounds both sellers list at 1 cent — the floors are ignored entirely.

Logs

[reprice] round 84212: A=1 B=1 (floors: 800, 795)

The code as shipped

src/market/repricer.js (editable)

// Simulates two repricing bots undercutting each other (cents).
exports.battle = function (priceA, priceB, floorA, floorB, rounds) {
  var a = priceA, b = priceB;
  for (var i = 0; i < rounds; i++) {
    a = b - 1;
    b = a - 1;
  }
  return [a, b];
};

Open the hunt to edit the files, run the visible tests and submit against the hidden ones. More JavaScript bug hunts.