broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(base_price, sales, qty, reputation):
    bonus = {'neutral': 0, 'friendly': 5, 'honored': 10}[reputation]
    gold = 0
    sold = 0
    for i in range(qty):
        done = sold
        if done >= 20:
            break
        sat = min(60, 5 * done)
        unit = base_price * (100 - sat) // 100
        unit = unit * (100 + bonus) // 100
        gold += max(1, unit)
        sold += 1
    return {'gold': gold, 'sold': sold, 'returned': qty - sold}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression prior sales carry #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0}),
  ('regression prior sales carry #2', [3, 1, 11, 'neutral'], {'gold': 17, 'sold': 11, 'returned': 0}),
  ('partial repair boundary #1', [10, 0, 7, 'friendly'], {'gold': 58, 'sold': 7, 'returned': 0}),
  ('regression prior sales carry #3', [10, 5, 10, 'friendly'], {'gold': 52, 'sold': 10, 'returned': 0}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [1, 22, 0, 'honored'], {'gold': 0, 'sold': 0, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression prior sales carry #1', [3, 1, 11, 'neutral'], {'gold': 17, 'sold': 11, 'returned': 0}),
  ('fault site prior sales carry #1', [2, 22, 2, 'friendly'], {'gold': 0, 'sold': 0, 'returned': 2}),
  ('partial repair boundary #1', [10, 0, 7, 'friendly'], {'gold': 58, 'sold': 7, 'returned': 0}),
  ('regression prior sales carry #2', [10, 5, 10, 'friendly'], {'gold': 52, 'sold': 10, 'returned': 0}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [1, 22, 0, 'honored'], {'gold': 0, 'sold': 0, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('fault site prior sales carry #1', [190, 12, 7, 'neutral'], {'gold': 532, 'sold': 7, 'returned': 0}),
  ('regression prior sales carry #1', [10, 5, 10, 'friendly'], {'gold': 52, 'sold': 10, 'returned': 0}),
  ('regression prior sales carry #2', [2, 15, 10, 'neutral'], {'gold': 5, 'sold': 5, 'returned': 5}),
  ('regression prior sales carry #3', [25, 1, 4, 'neutral'], {'gold': 86, 'sold': 4, 'returned': 0}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [1, 22, 0, 'honored'], {'gold': 0, 'sold': 0, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression prior sales carry #1', [2, 15, 10, 'neutral'], {'gold': 5, 'sold': 5, 'returned': 5}),
  ('regression prior sales carry #2', [25, 1, 4, 'neutral'], {'gold': 86, 'sold': 4, 'returned': 0}),
  ('regression prior sales carry #3', [10, 1, 9, 'friendly'], {'gold': 65, 'sold': 9, 'returned': 0}),
  ('regression prior sales carry #4', [25, 12, 12, 'neutral'], {'gold': 80, 'sold': 8, 'returned': 4}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [55, 5, 0, 'neutral'], {'gold': 0, 'sold': 0, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('fault site prior sales carry #1', [3, 12, 4, 'honored'], {'gold': 4, 'sold': 4, 'returned': 0}),
  ('regression prior sales carry #1', [10, 1, 9, 'friendly'], {'gold': 65, 'sold': 9, 'returned': 0}),
  ('regression prior sales carry #2', [25, 12, 12, 'neutral'], {'gold': 80, 'sold': 8, 'returned': 4}),
  ('regression prior sales carry #3', [99, 11, 5, 'neutral'], {'gold': 200, 'sold': 5, 'returned': 0}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [1, 0, 8, 'honored'], {'gold': 8, 'sold': 8, 'returned': 0})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(base_price, sales, qty, reputation):
    bonus = {'neutral': 0, 'friendly': 5, 'honored': 10}[reputation]
    gold = 0
    sold = 0
    for i in range(qty):
        done = sales
        if done >= 20:
            break
        sat = min(60, 5 * done)
        unit = base_price * (100 - sat) // 100
        unit = unit * (100 + bonus) // 100
        gold += max(1, unit)
        sold += 1
    return {'gold': gold, 'sold': sold, 'returned': qty - sold}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression prior sales carry #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0}),
  ('regression prior sales carry #2', [3, 1, 11, 'neutral'], {'gold': 17, 'sold': 11, 'returned': 0}),
  ('partial repair boundary #1', [10, 0, 7, 'friendly'], {'gold': 58, 'sold': 7, 'returned': 0}),
  ('regression prior sales carry #3', [10, 5, 10, 'friendly'], {'gold': 52, 'sold': 10, 'returned': 0}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [1, 22, 0, 'honored'], {'gold': 0, 'sold': 0, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression prior sales carry #1', [3, 1, 11, 'neutral'], {'gold': 17, 'sold': 11, 'returned': 0}),
  ('fault site prior sales carry #1', [2, 22, 2, 'friendly'], {'gold': 0, 'sold': 0, 'returned': 2}),
  ('partial repair boundary #1', [10, 0, 7, 'friendly'], {'gold': 58, 'sold': 7, 'returned': 0}),
  ('regression prior sales carry #2', [10, 5, 10, 'friendly'], {'gold': 52, 'sold': 10, 'returned': 0}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [1, 22, 0, 'honored'], {'gold': 0, 'sold': 0, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('fault site prior sales carry #1', [190, 12, 7, 'neutral'], {'gold': 532, 'sold': 7, 'returned': 0}),
  ('regression prior sales carry #1', [10, 5, 10, 'friendly'], {'gold': 52, 'sold': 10, 'returned': 0}),
  ('regression prior sales carry #2', [2, 15, 10, 'neutral'], {'gold': 5, 'sold': 5, 'returned': 5}),
  ('regression prior sales carry #3', [25, 1, 4, 'neutral'], {'gold': 86, 'sold': 4, 'returned': 0}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [1, 22, 0, 'honored'], {'gold': 0, 'sold': 0, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression prior sales carry #1', [2, 15, 10, 'neutral'], {'gold': 5, 'sold': 5, 'returned': 5}),
  ('regression prior sales carry #2', [25, 1, 4, 'neutral'], {'gold': 86, 'sold': 4, 'returned': 0}),
  ('regression prior sales carry #3', [10, 1, 9, 'friendly'], {'gold': 65, 'sold': 9, 'returned': 0}),
  ('regression prior sales carry #4', [25, 12, 12, 'neutral'], {'gold': 80, 'sold': 8, 'returned': 4}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [55, 5, 0, 'neutral'], {'gold': 0, 'sold': 0, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('fault site prior sales carry #1', [3, 12, 4, 'honored'], {'gold': 4, 'sold': 4, 'returned': 0}),
  ('regression prior sales carry #1', [10, 1, 9, 'friendly'], {'gold': 65, 'sold': 9, 'returned': 0}),
  ('regression prior sales carry #2', [25, 12, 12, 'neutral'], {'gold': 80, 'sold': 8, 'returned': 4}),
  ('regression prior sales carry #3', [99, 11, 5, 'neutral'], {'gold': 200, 'sold': 5, 'returned': 0}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [1, 0, 8, 'honored'], {'gold': 8, 'sold': 8, 'returned': 0})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Splitting sales into many small trips resets vendor saturation.

Selling qty units after `sales` units already sold today. Daily cap 20 units total; excess is returned. Per unit, with done = units sold today before it: saturation = min(60, 5*done) percent; unit = floor(base*(100-sat)/100), then floor(unit*(100+bonus)/100) with bonus neutral 0, friendly 5, honored 10; each unit pays at least 1.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(base_price, sales, qty, reputation):
    bonus = {'neutral': 0, 'friendly': 5, 'honored': 10}[reputation]
    gold = 0
    sold = 0
    for i in range(qty):
        done = sales + sold
        if done > 20:
            break
        sat = min(60, 5 * done)
        unit = base_price * (100 - sat) // 100
        unit = unit * (100 + bonus) // 100
        gold += max(1, unit)
        sold += 1
    return {'gold': gold, 'sold': sold, 'returned': qty - sold}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression daily cap check #1', [2, 15, 10, 'neutral'], {'gold': 5, 'sold': 5, 'returned': 5}),
  ('regression daily cap check #2', [3, 20, 3, 'honored'], {'gold': 0, 'sold': 0, 'returned': 3}),
  ('partial repair boundary #1', [2, 22, 2, 'friendly'], {'gold': 0, 'sold': 0, 'returned': 2}),
  ('partial repair boundary #2', [3, 22, 4, 'honored'], {'gold': 0, 'sold': 0, 'returned': 4}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression daily cap check #1', [3, 20, 3, 'honored'], {'gold': 0, 'sold': 0, 'returned': 3}),
  ('regression daily cap check #2', [25, 12, 12, 'neutral'], {'gold': 80, 'sold': 8, 'returned': 4}),
  ('regression daily cap check #3', [2, 15, 10, 'neutral'], {'gold': 5, 'sold': 5, 'returned': 5}),
  ('partial repair boundary #1', [3, 22, 4, 'honored'], {'gold': 0, 'sold': 0, 'returned': 4}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression daily cap check #1', [15, 15, 7, 'friendly'], {'gold': 30, 'sold': 5, 'returned': 2}),
  ('regression daily cap check #2', [99, 20, 9, 'honored'], {'gold': 0, 'sold': 0, 'returned': 9}),
  ('partial repair boundary #1', [3, 22, 4, 'honored'], {'gold': 0, 'sold': 0, 'returned': 4}),
  ('partial repair boundary #2', [10, 22, 10, 'neutral'], {'gold': 0, 'sold': 0, 'returned': 10}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression daily cap check #1', [99, 19, 4, 'friendly'], {'gold': 40, 'sold': 1, 'returned': 3}),
  ('regression daily cap check #2', [99, 20, 7, 'neutral'], {'gold': 0, 'sold': 0, 'returned': 7}),
  ('regression daily cap check #3', [25, 12, 12, 'neutral'], {'gold': 80, 'sold': 8, 'returned': 4}),
  ('regression daily cap check #4', [15, 15, 7, 'friendly'], {'gold': 30, 'sold': 5, 'returned': 2}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [3, 1, 11, 'neutral'], {'gold': 17, 'sold': 11, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression daily cap check #1', [1, 15, 12, 'friendly'], {'gold': 5, 'sold': 5, 'returned': 7}),
  ('regression daily cap check #2', [10, 20, 7, 'honored'], {'gold': 0, 'sold': 0, 'returned': 7}),
  ('regression daily cap check #3', [99, 20, 9, 'honored'], {'gold': 0, 'sold': 0, 'returned': 9}),
  ('regression daily cap check #4', [99, 19, 4, 'friendly'], {'gold': 40, 'sold': 1, 'returned': 3}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [10, 0, 7, 'friendly'], {'gold': 58, 'sold': 7, 'returned': 0})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(base_price, sales, qty, reputation):
    bonus = {'neutral': 0, 'friendly': 5, 'honored': 10}[reputation]
    gold = 0
    sold = 0
    for i in range(qty):
        done = sales + sold
        if sold >= 20:
            break
        sat = min(60, 5 * done)
        unit = base_price * (100 - sat) // 100
        unit = unit * (100 + bonus) // 100
        gold += max(1, unit)
        sold += 1
    return {'gold': gold, 'sold': sold, 'returned': qty - sold}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression daily cap check #1', [2, 15, 10, 'neutral'], {'gold': 5, 'sold': 5, 'returned': 5}),
  ('regression daily cap check #2', [3, 20, 3, 'honored'], {'gold': 0, 'sold': 0, 'returned': 3}),
  ('partial repair boundary #1', [2, 22, 2, 'friendly'], {'gold': 0, 'sold': 0, 'returned': 2}),
  ('partial repair boundary #2', [3, 22, 4, 'honored'], {'gold': 0, 'sold': 0, 'returned': 4}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression daily cap check #1', [3, 20, 3, 'honored'], {'gold': 0, 'sold': 0, 'returned': 3}),
  ('regression daily cap check #2', [25, 12, 12, 'neutral'], {'gold': 80, 'sold': 8, 'returned': 4}),
  ('regression daily cap check #3', [2, 15, 10, 'neutral'], {'gold': 5, 'sold': 5, 'returned': 5}),
  ('partial repair boundary #1', [3, 22, 4, 'honored'], {'gold': 0, 'sold': 0, 'returned': 4}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression daily cap check #1', [15, 15, 7, 'friendly'], {'gold': 30, 'sold': 5, 'returned': 2}),
  ('regression daily cap check #2', [99, 20, 9, 'honored'], {'gold': 0, 'sold': 0, 'returned': 9}),
  ('partial repair boundary #1', [3, 22, 4, 'honored'], {'gold': 0, 'sold': 0, 'returned': 4}),
  ('partial repair boundary #2', [10, 22, 10, 'neutral'], {'gold': 0, 'sold': 0, 'returned': 10}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression daily cap check #1', [99, 19, 4, 'friendly'], {'gold': 40, 'sold': 1, 'returned': 3}),
  ('regression daily cap check #2', [99, 20, 7, 'neutral'], {'gold': 0, 'sold': 0, 'returned': 7}),
  ('regression daily cap check #3', [25, 12, 12, 'neutral'], {'gold': 80, 'sold': 8, 'returned': 4}),
  ('regression daily cap check #4', [15, 15, 7, 'friendly'], {'gold': 30, 'sold': 5, 'returned': 2}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [3, 1, 11, 'neutral'], {'gold': 17, 'sold': 11, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression daily cap check #1', [1, 15, 12, 'friendly'], {'gold': 5, 'sold': 5, 'returned': 7}),
  ('regression daily cap check #2', [10, 20, 7, 'honored'], {'gold': 0, 'sold': 0, 'returned': 7}),
  ('regression daily cap check #3', [99, 20, 9, 'honored'], {'gold': 0, 'sold': 0, 'returned': 9}),
  ('regression daily cap check #4', [99, 19, 4, 'friendly'], {'gold': 40, 'sold': 1, 'returned': 3}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [10, 0, 7, 'friendly'], {'gold': 58, 'sold': 7, 'returned': 0})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The daily cap admits one unit too many.

Selling qty units after `sales` units already sold today. Daily cap 20 units total; excess is returned. Per unit, with done = units sold today before it: saturation = min(60, 5*done) percent; unit = floor(base*(100-sat)/100), then floor(unit*(100+bonus)/100) with bonus neutral 0, friendly 5, honored 10; each unit pays at least 1.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(base_price, sales, qty, reputation):
    bonus = {'neutral': 0, 'friendly': 5, 'honored': 10}[reputation]
    gold = 0
    sold = 0
    for i in range(qty):
        done = sales + sold
        if done >= 20:
            break
        sat = 5 * done
        unit = base_price * (100 - sat) // 100
        unit = unit * (100 + bonus) // 100
        gold += max(1, unit)
        sold += 1
    return {'gold': gold, 'sold': sold, 'returned': qty - sold}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression saturation ceiling #1', [190, 12, 7, 'neutral'], {'gold': 532, 'sold': 7, 'returned': 0}),
  ('regression saturation ceiling #2', [10, 5, 10, 'friendly'], {'gold': 52, 'sold': 10, 'returned': 0}),
  ('regression saturation ceiling #3', [7, 12, 6, 'neutral'], {'gold': 12, 'sold': 6, 'returned': 0}),
  ('regression saturation ceiling #4', [25, 12, 12, 'neutral'], {'gold': 80, 'sold': 8, 'returned': 4}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression saturation ceiling #1', [10, 5, 10, 'friendly'], {'gold': 52, 'sold': 10, 'returned': 0}),
  ('regression saturation ceiling #2', [7, 12, 6, 'neutral'], {'gold': 12, 'sold': 6, 'returned': 0}),
  ('regression saturation ceiling #3', [25, 12, 12, 'neutral'], {'gold': 80, 'sold': 8, 'returned': 4}),
  ('regression saturation ceiling #4', [99, 11, 5, 'neutral'], {'gold': 200, 'sold': 5, 'returned': 0}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression saturation ceiling #1', [25, 12, 12, 'neutral'], {'gold': 80, 'sold': 8, 'returned': 4}),
  ('regression saturation ceiling #2', [99, 11, 5, 'neutral'], {'gold': 200, 'sold': 5, 'returned': 0}),
  ('regression saturation ceiling #3', [15, 15, 7, 'friendly'], {'gold': 30, 'sold': 5, 'returned': 2}),
  ('regression saturation ceiling #4', [99, 12, 4, 'friendly'], {'gold': 160, 'sold': 4, 'returned': 0}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression saturation ceiling #1', [15, 15, 7, 'friendly'], {'gold': 30, 'sold': 5, 'returned': 2}),
  ('regression saturation ceiling #2', [99, 12, 4, 'friendly'], {'gold': 160, 'sold': 4, 'returned': 0}),
  ('regression saturation ceiling #3', [99, 19, 4, 'friendly'], {'gold': 40, 'sold': 1, 'returned': 3}),
  ('regression saturation ceiling #4', [99, 15, 5, 'honored'], {'gold': 210, 'sold': 5, 'returned': 0}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [3, 1, 11, 'neutral'], {'gold': 17, 'sold': 11, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression saturation ceiling #1', [99, 19, 4, 'friendly'], {'gold': 40, 'sold': 1, 'returned': 3}),
  ('regression saturation ceiling #2', [99, 15, 5, 'honored'], {'gold': 210, 'sold': 5, 'returned': 0}),
  ('regression saturation ceiling #3', [70, 11, 3, 'friendly'], {'gold': 90, 'sold': 3, 'returned': 0}),
  ('regression saturation ceiling #4', [160, 15, 12, 'friendly'], {'gold': 335, 'sold': 5, 'returned': 7}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [10, 0, 7, 'friendly'], {'gold': 58, 'sold': 7, 'returned': 0})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(base_price, sales, qty, reputation):
    bonus = {'neutral': 0, 'friendly': 5, 'honored': 10}[reputation]
    gold = 0
    sold = 0
    for i in range(qty):
        done = sales + sold
        if done >= 20:
            break
        sat = min(50, 5 * done)
        unit = base_price * (100 - sat) // 100
        unit = unit * (100 + bonus) // 100
        gold += max(1, unit)
        sold += 1
    return {'gold': gold, 'sold': sold, 'returned': qty - sold}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression saturation ceiling #1', [190, 12, 7, 'neutral'], {'gold': 532, 'sold': 7, 'returned': 0}),
  ('regression saturation ceiling #2', [10, 5, 10, 'friendly'], {'gold': 52, 'sold': 10, 'returned': 0}),
  ('regression saturation ceiling #3', [7, 12, 6, 'neutral'], {'gold': 12, 'sold': 6, 'returned': 0}),
  ('regression saturation ceiling #4', [25, 12, 12, 'neutral'], {'gold': 80, 'sold': 8, 'returned': 4}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression saturation ceiling #1', [10, 5, 10, 'friendly'], {'gold': 52, 'sold': 10, 'returned': 0}),
  ('regression saturation ceiling #2', [7, 12, 6, 'neutral'], {'gold': 12, 'sold': 6, 'returned': 0}),
  ('regression saturation ceiling #3', [25, 12, 12, 'neutral'], {'gold': 80, 'sold': 8, 'returned': 4}),
  ('regression saturation ceiling #4', [99, 11, 5, 'neutral'], {'gold': 200, 'sold': 5, 'returned': 0}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression saturation ceiling #1', [25, 12, 12, 'neutral'], {'gold': 80, 'sold': 8, 'returned': 4}),
  ('regression saturation ceiling #2', [99, 11, 5, 'neutral'], {'gold': 200, 'sold': 5, 'returned': 0}),
  ('regression saturation ceiling #3', [15, 15, 7, 'friendly'], {'gold': 30, 'sold': 5, 'returned': 2}),
  ('regression saturation ceiling #4', [99, 12, 4, 'friendly'], {'gold': 160, 'sold': 4, 'returned': 0}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression saturation ceiling #1', [15, 15, 7, 'friendly'], {'gold': 30, 'sold': 5, 'returned': 2}),
  ('regression saturation ceiling #2', [99, 12, 4, 'friendly'], {'gold': 160, 'sold': 4, 'returned': 0}),
  ('regression saturation ceiling #3', [99, 19, 4, 'friendly'], {'gold': 40, 'sold': 1, 'returned': 3}),
  ('regression saturation ceiling #4', [99, 15, 5, 'honored'], {'gold': 210, 'sold': 5, 'returned': 0}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [3, 1, 11, 'neutral'], {'gold': 17, 'sold': 11, 'returned': 0})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression saturation ceiling #1', [99, 19, 4, 'friendly'], {'gold': 40, 'sold': 1, 'returned': 3}),
  ('regression saturation ceiling #2', [99, 15, 5, 'honored'], {'gold': 210, 'sold': 5, 'returned': 0}),
  ('regression saturation ceiling #3', [70, 11, 3, 'friendly'], {'gold': 90, 'sold': 3, 'returned': 0}),
  ('regression saturation ceiling #4', [160, 15, 12, 'friendly'], {'gold': 335, 'sold': 5, 'returned': 7}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [10, 0, 7, 'friendly'], {'gold': 58, 'sold': 7, 'returned': 0})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Late sales collapse to the one-coin minimum instead of 40% value.

Selling qty units after `sales` units already sold today. Daily cap 20 units total; excess is returned. Per unit, with done = units sold today before it: saturation = min(60, 5*done) percent; unit = floor(base*(100-sat)/100), then floor(unit*(100+bonus)/100) with bonus neutral 0, friendly 5, honored 10; each unit pays at least 1.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(base_price, sales, qty, reputation):
    bonus = {'neutral': 0, 'friendly': 5, 'honored': 10}[reputation]
    gold = 0
    sold = 0
    for i in range(qty):
        done = sales + sold
        if done >= 20:
            break
        sat = min(60, 5 * done)
        unit = -(-base_price * (100 - sat) // 100)
        unit = unit * (100 + bonus) // 100
        gold += max(1, unit)
        sold += 1
    return {'gold': gold, 'sold': sold, 'returned': qty - sold}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('fault site saturation rounding #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0}),
  ('regression saturation rounding #1', [3, 1, 11, 'neutral'], {'gold': 17, 'sold': 11, 'returned': 0}),
  ('regression saturation rounding #2', [10, 0, 7, 'friendly'], {'gold': 58, 'sold': 7, 'returned': 0}),
  ('regression saturation rounding #3', [10, 5, 10, 'friendly'], {'gold': 52, 'sold': 10, 'returned': 0}),
  ('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [2, 22, 2, 'friendly'], {'gold': 0, 'sold': 0, 'returned': 2})],
 [('regression saturation rounding #1', [10, 0, 7, 'friendly'], {'gold': 58, 'sold': 7, 'returned': 0}),
  ('regression saturation rounding #2', [10, 5, 10, 'friendly'], {'gold': 52, 'sold': 10, 'returned': 0}),
  ('regression saturation rounding #3', [25, 1, 4, 'neutral'], {'gold': 86, 'sold': 4, 'returned': 0}),
  ('regression saturation rounding #4', [10, 1, 9, 'friendly'], {'gold': 65, 'sold': 9, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('control #1', [2, 22, 2, 'friendly'], {'gold': 0, 'sold': 0, 'returned': 2}),
  ('control #2', [190, 12, 7, 'neutral'], {'gold': 532, 'sold': 7, 'returned': 0})],
 [('regression saturation rounding #1', [25, 1, 4, 'neutral'], {'gold': 86, 'sold': 4, 'returned': 0}),
  ('fault site saturation rounding #1', [3, 12, 4, 'honored'], {'gold': 4, 'sold': 4, 'returned': 0}),
  ('regression saturation rounding #2', [10, 1, 9, 'friendly'], {'gold': 65, 'sold': 9, 'returned': 0}),
  ('regression saturation rounding #3', [7, 12, 6, 'neutral'], {'gold': 12, 'sold': 6, 'returned': 0}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [190, 12, 7, 'neutral'], {'gold': 532, 'sold': 7, 'returned': 0}),
  ('control #2', [2, 15, 10, 'neutral'], {'gold': 5, 'sold': 5, 'returned': 5})],
 [('regression saturation rounding #1', [10, 1, 9, 'friendly'], {'gold': 65, 'sold': 9, 'returned': 0}),
  ('fault site saturation rounding #1', [7, 11, 1, 'honored'], {'gold': 3, 'sold': 1, 'returned': 0}),
  ('regression saturation rounding #2', [99, 11, 5, 'neutral'], {'gold': 200, 'sold': 5, 'returned': 0}),
  ('regression saturation rounding #3', [2, 1, 5, 'honored'], {'gold': 5, 'sold': 5, 'returned': 0}),
  ('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('control #1', [3, 20, 3, 'honored'], {'gold': 0, 'sold': 0, 'returned': 3}),
  ('control #2', [3, 22, 4, 'honored'], {'gold': 0, 'sold': 0, 'returned': 4})],
 [('regression saturation rounding #1', [7, 12, 6, 'neutral'], {'gold': 12, 'sold': 6, 'returned': 0}),
  ('regression saturation rounding #2', [99, 11, 5, 'neutral'], {'gold': 200, 'sold': 5, 'returned': 0}),
  ('regression saturation rounding #3', [99, 12, 4, 'friendly'], {'gold': 160, 'sold': 4, 'returned': 0}),
  ('regression saturation rounding #4', [3, 1, 12, 'honored'], {'gold': 18, 'sold': 12, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('control #1', [10, 22, 10, 'neutral'], {'gold': 0, 'sold': 0, 'returned': 10}),
  ('control #2', [25, 12, 12, 'neutral'], {'gold': 80, 'sold': 8, 'returned': 4})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(base_price, sales, qty, reputation):
    bonus = {'neutral': 0, 'friendly': 5, 'honored': 10}[reputation]
    gold = 0
    sold = 0
    for i in range(qty):
        done = sales + sold
        if done >= 20:
            break
        sat = min(60, 5 * done)
        unit = round(base_price * (100 - sat) / 100)
        unit = unit * (100 + bonus) // 100
        gold += max(1, unit)
        sold += 1
    return {'gold': gold, 'sold': sold, 'returned': qty - sold}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('fault site saturation rounding #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0}),
  ('regression saturation rounding #1', [3, 1, 11, 'neutral'], {'gold': 17, 'sold': 11, 'returned': 0}),
  ('regression saturation rounding #2', [10, 0, 7, 'friendly'], {'gold': 58, 'sold': 7, 'returned': 0}),
  ('regression saturation rounding #3', [10, 5, 10, 'friendly'], {'gold': 52, 'sold': 10, 'returned': 0}),
  ('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [2, 22, 2, 'friendly'], {'gold': 0, 'sold': 0, 'returned': 2})],
 [('regression saturation rounding #1', [10, 0, 7, 'friendly'], {'gold': 58, 'sold': 7, 'returned': 0}),
  ('regression saturation rounding #2', [10, 5, 10, 'friendly'], {'gold': 52, 'sold': 10, 'returned': 0}),
  ('regression saturation rounding #3', [25, 1, 4, 'neutral'], {'gold': 86, 'sold': 4, 'returned': 0}),
  ('regression saturation rounding #4', [10, 1, 9, 'friendly'], {'gold': 65, 'sold': 9, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('control #1', [2, 22, 2, 'friendly'], {'gold': 0, 'sold': 0, 'returned': 2}),
  ('control #2', [190, 12, 7, 'neutral'], {'gold': 532, 'sold': 7, 'returned': 0})],
 [('regression saturation rounding #1', [25, 1, 4, 'neutral'], {'gold': 86, 'sold': 4, 'returned': 0}),
  ('fault site saturation rounding #1', [3, 12, 4, 'honored'], {'gold': 4, 'sold': 4, 'returned': 0}),
  ('regression saturation rounding #2', [10, 1, 9, 'friendly'], {'gold': 65, 'sold': 9, 'returned': 0}),
  ('regression saturation rounding #3', [7, 12, 6, 'neutral'], {'gold': 12, 'sold': 6, 'returned': 0}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [190, 12, 7, 'neutral'], {'gold': 532, 'sold': 7, 'returned': 0}),
  ('control #2', [2, 15, 10, 'neutral'], {'gold': 5, 'sold': 5, 'returned': 5})],
 [('regression saturation rounding #1', [10, 1, 9, 'friendly'], {'gold': 65, 'sold': 9, 'returned': 0}),
  ('fault site saturation rounding #1', [7, 11, 1, 'honored'], {'gold': 3, 'sold': 1, 'returned': 0}),
  ('regression saturation rounding #2', [99, 11, 5, 'neutral'], {'gold': 200, 'sold': 5, 'returned': 0}),
  ('regression saturation rounding #3', [2, 1, 5, 'honored'], {'gold': 5, 'sold': 5, 'returned': 0}),
  ('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('control #1', [3, 20, 3, 'honored'], {'gold': 0, 'sold': 0, 'returned': 3}),
  ('control #2', [3, 22, 4, 'honored'], {'gold': 0, 'sold': 0, 'returned': 4})],
 [('regression saturation rounding #1', [7, 12, 6, 'neutral'], {'gold': 12, 'sold': 6, 'returned': 0}),
  ('regression saturation rounding #2', [99, 11, 5, 'neutral'], {'gold': 200, 'sold': 5, 'returned': 0}),
  ('regression saturation rounding #3', [99, 12, 4, 'friendly'], {'gold': 160, 'sold': 4, 'returned': 0}),
  ('regression saturation rounding #4', [3, 1, 12, 'honored'], {'gold': 18, 'sold': 12, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('control #1', [10, 22, 10, 'neutral'], {'gold': 0, 'sold': 0, 'returned': 10}),
  ('control #2', [25, 12, 12, 'neutral'], {'gold': 80, 'sold': 8, 'returned': 4})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Vendors pay fractional coins upward, leaking currency.

Selling qty units after `sales` units already sold today. Daily cap 20 units total; excess is returned. Per unit, with done = units sold today before it: saturation = min(60, 5*done) percent; unit = floor(base*(100-sat)/100), then floor(unit*(100+bonus)/100) with bonus neutral 0, friendly 5, honored 10; each unit pays at least 1.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(base_price, sales, qty, reputation):
    bonus = {'neutral': 0, 'friendly': 5, 'honored': 10}[reputation]
    gold = 0
    sold = 0
    for i in range(qty):
        done = sales + sold
        if done >= 20:
            break
        sat = min(60, 5 * done)
        unit = base_price * (100 - sat) // 100
        unit = unit + bonus
        gold += max(1, unit)
        sold += 1
    return {'gold': gold, 'sold': sold, 'returned': qty - sold}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('regression reputation bonus form #1', [10, 0, 7, 'friendly'], {'gold': 58, 'sold': 7, 'returned': 0}),
  ('partial repair boundary #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0}),
  ('partial repair boundary #2', [3, 1, 11, 'neutral'], {'gold': 17, 'sold': 11, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [2, 22, 2, 'friendly'], {'gold': 0, 'sold': 0, 'returned': 2}),
  ('control #2', [3, 20, 3, 'honored'], {'gold': 0, 'sold': 0, 'returned': 3})],
 [('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression reputation bonus form #1', [10, 0, 7, 'friendly'], {'gold': 58, 'sold': 7, 'returned': 0}),
  ('regression reputation bonus form #2', [10, 5, 10, 'friendly'], {'gold': 52, 'sold': 10, 'returned': 0}),
  ('partial repair boundary #1', [3, 1, 11, 'neutral'], {'gold': 17, 'sold': 11, 'returned': 0}),
  ('partial repair boundary #2', [190, 12, 7, 'neutral'], {'gold': 532, 'sold': 7, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [2, 22, 2, 'friendly'], {'gold': 0, 'sold': 0, 'returned': 2})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression reputation bonus form #1', [3, 12, 4, 'honored'], {'gold': 4, 'sold': 4, 'returned': 0}),
  ('regression reputation bonus form #2', [10, 1, 9, 'friendly'], {'gold': 65, 'sold': 9, 'returned': 0}),
  ('partial repair boundary #1', [190, 12, 7, 'neutral'], {'gold': 532, 'sold': 7, 'returned': 0}),
  ('regression reputation bonus form #3', [10, 5, 10, 'friendly'], {'gold': 52, 'sold': 10, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [10, 22, 10, 'neutral'], {'gold': 0, 'sold': 0, 'returned': 10}),
  ('control #2', [99, 20, 9, 'honored'], {'gold': 0, 'sold': 0, 'returned': 9})],
 [('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression reputation bonus form #1', [7, 11, 1, 'honored'], {'gold': 3, 'sold': 1, 'returned': 0}),
  ('regression reputation bonus form #2', [15, 15, 7, 'friendly'], {'gold': 30, 'sold': 5, 'returned': 2}),
  ('partial repair boundary #1', [2, 15, 10, 'neutral'], {'gold': 5, 'sold': 5, 'returned': 5}),
  ('partial repair boundary #2', [25, 1, 4, 'neutral'], {'gold': 86, 'sold': 4, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [3, 22, 4, 'honored'], {'gold': 0, 'sold': 0, 'returned': 4})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression reputation bonus form #1', [2, 1, 5, 'honored'], {'gold': 5, 'sold': 5, 'returned': 0}),
  ('regression reputation bonus form #2', [99, 12, 4, 'friendly'], {'gold': 160, 'sold': 4, 'returned': 0}),
  ('regression reputation bonus form #3', [3, 12, 4, 'honored'], {'gold': 4, 'sold': 4, 'returned': 0}),
  ('regression reputation bonus form #4', [10, 1, 9, 'friendly'], {'gold': 65, 'sold': 9, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [7, 22, 10, 'honored'], {'gold': 0, 'sold': 0, 'returned': 10}),
  ('control #2', [55, 5, 0, 'neutral'], {'gold': 0, 'sold': 0, 'returned': 0})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(base_price, sales, qty, reputation):
    bonus = {'neutral': 0, 'friendly': 5, 'honored': 10}[reputation]
    gold = 0
    sold = 0
    for i in range(qty):
        done = sales + sold
        if done >= 20:
            break
        sat = min(60, 5 * done)
        unit = base_price * (100 - sat) // 100
        unit = base_price * (100 + bonus) // 100
        gold += max(1, unit)
        sold += 1
    return {'gold': gold, 'sold': sold, 'returned': qty - sold}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('regression reputation bonus form #1', [10, 0, 7, 'friendly'], {'gold': 58, 'sold': 7, 'returned': 0}),
  ('partial repair boundary #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0}),
  ('partial repair boundary #2', [3, 1, 11, 'neutral'], {'gold': 17, 'sold': 11, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [2, 22, 2, 'friendly'], {'gold': 0, 'sold': 0, 'returned': 2}),
  ('control #2', [3, 20, 3, 'honored'], {'gold': 0, 'sold': 0, 'returned': 3})],
 [('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression reputation bonus form #1', [10, 0, 7, 'friendly'], {'gold': 58, 'sold': 7, 'returned': 0}),
  ('regression reputation bonus form #2', [10, 5, 10, 'friendly'], {'gold': 52, 'sold': 10, 'returned': 0}),
  ('partial repair boundary #1', [3, 1, 11, 'neutral'], {'gold': 17, 'sold': 11, 'returned': 0}),
  ('partial repair boundary #2', [190, 12, 7, 'neutral'], {'gold': 532, 'sold': 7, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [2, 22, 2, 'friendly'], {'gold': 0, 'sold': 0, 'returned': 2})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression reputation bonus form #1', [3, 12, 4, 'honored'], {'gold': 4, 'sold': 4, 'returned': 0}),
  ('regression reputation bonus form #2', [10, 1, 9, 'friendly'], {'gold': 65, 'sold': 9, 'returned': 0}),
  ('partial repair boundary #1', [190, 12, 7, 'neutral'], {'gold': 532, 'sold': 7, 'returned': 0}),
  ('regression reputation bonus form #3', [10, 5, 10, 'friendly'], {'gold': 52, 'sold': 10, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [10, 22, 10, 'neutral'], {'gold': 0, 'sold': 0, 'returned': 10}),
  ('control #2', [99, 20, 9, 'honored'], {'gold': 0, 'sold': 0, 'returned': 9})],
 [('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression reputation bonus form #1', [7, 11, 1, 'honored'], {'gold': 3, 'sold': 1, 'returned': 0}),
  ('regression reputation bonus form #2', [15, 15, 7, 'friendly'], {'gold': 30, 'sold': 5, 'returned': 2}),
  ('partial repair boundary #1', [2, 15, 10, 'neutral'], {'gold': 5, 'sold': 5, 'returned': 5}),
  ('partial repair boundary #2', [25, 1, 4, 'neutral'], {'gold': 86, 'sold': 4, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [3, 22, 4, 'honored'], {'gold': 0, 'sold': 0, 'returned': 4})],
 [('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('regression reputation bonus form #1', [2, 1, 5, 'honored'], {'gold': 5, 'sold': 5, 'returned': 0}),
  ('regression reputation bonus form #2', [99, 12, 4, 'friendly'], {'gold': 160, 'sold': 4, 'returned': 0}),
  ('regression reputation bonus form #3', [3, 12, 4, 'honored'], {'gold': 4, 'sold': 4, 'returned': 0}),
  ('regression reputation bonus form #4', [10, 1, 9, 'friendly'], {'gold': 65, 'sold': 9, 'returned': 0}),
  ('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('control #1', [7, 22, 10, 'honored'], {'gold': 0, 'sold': 0, 'returned': 10}),
  ('control #2', [55, 5, 0, 'neutral'], {'gold': 0, 'sold': 0, 'returned': 0})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Cheap items gain a huge relative reputation bonus.

Selling qty units after `sales` units already sold today. Daily cap 20 units total; excess is returned. Per unit, with done = units sold today before it: saturation = min(60, 5*done) percent; unit = floor(base*(100-sat)/100), then floor(unit*(100+bonus)/100) with bonus neutral 0, friendly 5, honored 10; each unit pays at least 1.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(base_price, sales, qty, reputation):
    bonus = {'neutral': 0, 'friendly': 5, 'honored': 10}[reputation]
    gold = 0
    sold = 0
    for i in range(qty):
        done = sales + sold
        if done >= 20:
            break
        sat = min(60, 5 * done)
        unit = base_price * (100 - sat) // 100
        unit = unit * (100 + bonus) // 100
        gold += unit
        sold += 1
    return {'gold': gold, 'sold': sold, 'returned': qty - sold}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('regression minimum payout #1', [2, 15, 10, 'neutral'], {'gold': 5, 'sold': 5, 'returned': 5}),
  ('fault site minimum payout #1', [1, 0, 8, 'honored'], {'gold': 8, 'sold': 8, 'returned': 0}),
  ('regression minimum payout #2', [1, 15, 12, 'friendly'], {'gold': 5, 'sold': 5, 'returned': 7}),
  ('regression minimum payout #3', [1, 5, 8, 'neutral'], {'gold': 8, 'sold': 8, 'returned': 0}),
  ('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('control #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0})],
 [('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('fault site minimum payout #1', [1, 0, 8, 'honored'], {'gold': 8, 'sold': 8, 'returned': 0}),
  ('regression minimum payout #1', [1, 15, 12, 'friendly'], {'gold': 5, 'sold': 5, 'returned': 7}),
  ('regression minimum payout #2', [1, 5, 8, 'neutral'], {'gold': 8, 'sold': 8, 'returned': 0}),
  ('regression minimum payout #3', [1, 11, 7, 'neutral'], {'gold': 7, 'sold': 7, 'returned': 0}),
  ('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('control #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0})],
 [('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('regression minimum payout #1', [1, 5, 8, 'neutral'], {'gold': 8, 'sold': 8, 'returned': 0}),
  ('regression minimum payout #2', [1, 11, 7, 'neutral'], {'gold': 7, 'sold': 7, 'returned': 0}),
  ('regression minimum payout #3', [2, 5, 10, 'honored'], {'gold': 10, 'sold': 10, 'returned': 0}),
  ('regression minimum payout #4', [2, 19, 9, 'friendly'], {'gold': 1, 'sold': 1, 'returned': 8}),
  ('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('control #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0})],
 [('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('regression minimum payout #1', [2, 5, 10, 'honored'], {'gold': 10, 'sold': 10, 'returned': 0}),
  ('regression minimum payout #2', [2, 19, 9, 'friendly'], {'gold': 1, 'sold': 1, 'returned': 8}),
  ('regression minimum payout #3', [2, 19, 3, 'neutral'], {'gold': 1, 'sold': 1, 'returned': 2}),
  ('regression minimum payout #4', [2, 18, 4, 'neutral'], {'gold': 2, 'sold': 2, 'returned': 2}),
  ('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('control #1', [3, 1, 11, 'neutral'], {'gold': 17, 'sold': 11, 'returned': 0})],
 [('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('fault site minimum payout #1', [2, 1, 11, 'neutral'], {'gold': 11, 'sold': 11, 'returned': 0}),
  ('fault site minimum payout #2', [1, 5, 6, 'honored'], {'gold': 6, 'sold': 6, 'returned': 0}),
  ('regression minimum payout #1', [2, 18, 4, 'neutral'], {'gold': 2, 'sold': 2, 'returned': 2}),
  ('regression minimum payout #2', [1, 15, 2, 'neutral'], {'gold': 2, 'sold': 2, 'returned': 0}),
  ('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('control #1', [10, 0, 7, 'friendly'], {'gold': 58, 'sold': 7, 'returned': 0})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(base_price, sales, qty, reputation):
    bonus = {'neutral': 0, 'friendly': 5, 'honored': 10}[reputation]
    gold = 0
    sold = 0
    for i in range(qty):
        done = sales + sold
        if done >= 20:
            break
        sat = min(60, 5 * done)
        unit = base_price * (100 - sat) // 100
        unit = unit * (100 + bonus) // 100
        gold += max(1, unit) if sat < 60 else unit
        sold += 1
    return {'gold': gold, 'sold': sold, 'returned': qty - sold}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('regression minimum payout #1', [2, 15, 10, 'neutral'], {'gold': 5, 'sold': 5, 'returned': 5}),
  ('fault site minimum payout #1', [1, 0, 8, 'honored'], {'gold': 8, 'sold': 8, 'returned': 0}),
  ('regression minimum payout #2', [1, 15, 12, 'friendly'], {'gold': 5, 'sold': 5, 'returned': 7}),
  ('regression minimum payout #3', [1, 5, 8, 'neutral'], {'gold': 8, 'sold': 8, 'returned': 0}),
  ('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('control #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0})],
 [('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('fault site minimum payout #1', [1, 0, 8, 'honored'], {'gold': 8, 'sold': 8, 'returned': 0}),
  ('regression minimum payout #1', [1, 15, 12, 'friendly'], {'gold': 5, 'sold': 5, 'returned': 7}),
  ('regression minimum payout #2', [1, 5, 8, 'neutral'], {'gold': 8, 'sold': 8, 'returned': 0}),
  ('regression minimum payout #3', [1, 11, 7, 'neutral'], {'gold': 7, 'sold': 7, 'returned': 0}),
  ('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('control #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0})],
 [('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('regression minimum payout #1', [1, 5, 8, 'neutral'], {'gold': 8, 'sold': 8, 'returned': 0}),
  ('regression minimum payout #2', [1, 11, 7, 'neutral'], {'gold': 7, 'sold': 7, 'returned': 0}),
  ('regression minimum payout #3', [2, 5, 10, 'honored'], {'gold': 10, 'sold': 10, 'returned': 0}),
  ('regression minimum payout #4', [2, 19, 9, 'friendly'], {'gold': 1, 'sold': 1, 'returned': 8}),
  ('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('control #1', [99, 5, 3, 'neutral'], {'gold': 207, 'sold': 3, 'returned': 0})],
 [('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('regression minimum payout #1', [2, 5, 10, 'honored'], {'gold': 10, 'sold': 10, 'returned': 0}),
  ('regression minimum payout #2', [2, 19, 9, 'friendly'], {'gold': 1, 'sold': 1, 'returned': 8}),
  ('regression minimum payout #3', [2, 19, 3, 'neutral'], {'gold': 1, 'sold': 1, 'returned': 2}),
  ('regression minimum payout #4', [2, 18, 4, 'neutral'], {'gold': 2, 'sold': 2, 'returned': 2}),
  ('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('control #1', [3, 1, 11, 'neutral'], {'gold': 17, 'sold': 11, 'returned': 0})],
 [('cheap junk at saturation #1', [1, 12, 3, 'neutral'], {'gold': 3, 'sold': 3, 'returned': 0}),
  ('fault site minimum payout #1', [2, 1, 11, 'neutral'], {'gold': 11, 'sold': 11, 'returned': 0}),
  ('fault site minimum payout #2', [1, 5, 6, 'honored'], {'gold': 6, 'sold': 6, 'returned': 0}),
  ('regression minimum payout #1', [2, 18, 4, 'neutral'], {'gold': 2, 'sold': 2, 'returned': 2}),
  ('regression minimum payout #2', [1, 15, 2, 'neutral'], {'gold': 2, 'sold': 2, 'returned': 0}),
  ('cap reached mid batch #1', [40, 18, 5, 'honored'], {'gold': 34, 'sold': 2, 'returned': 3}),
  ('fresh day single sale #1', [9, 0, 1, 'friendly'], {'gold': 9, 'sold': 1, 'returned': 0}),
  ('control #1', [10, 0, 7, 'friendly'], {'gold': 58, 'sold': 7, 'returned': 0})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Low-value items pay nothing once saturated though a unit is consumed.

Selling qty units after `sales` units already sold today. Daily cap 20 units total; excess is returned. Per unit, with done = units sold today before it: saturation = min(60, 5*done) percent; unit = floor(base*(100-sat)/100), then floor(unit*(100+bonus)/100) with bonus neutral 0, friendly 5, honored 10; each unit pays at least 1.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(listing, outcome):
    blocks = listing['hours'] // 24
    per_block = max(1, listing['stack_value'] * 15 // 100)
    deposit = per_block * blocks
    status = outcome['status']
    if status == 'sold':
        cut = (listing['price'] * 5 + 50) // 100
        net = listing['price'] - cut
    elif status == 'cancelled':
        net = -deposit - outcome.get('bid', 0) * 5 // 100
    else:
        net = -deposit
    return {'deposit': deposit, 'net': net}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('long cheap listing #1',
   [{'price': 10, 'hours': 48, 'stack_value': 3}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('cancel with bid #1',
   [{'price': 500, 'hours': 24, 'stack_value': 40}, {'status': 'cancelled', 'bid': 390}],
   {'deposit': 12, 'net': -31}),
  ('half-up cut boundary #1',
   [{'price': 10, 'hours': 12, 'stack_value': 100}, {'status': 'sold'}],
   {'deposit': 15, 'net': 9}),
  ('regression duration blocks #1',
   [{'price': 11, 'hours': 24, 'stack_value': 13}, {'status': 'cancelled', 'bid': 0}],
   {'deposit': 2, 'net': -2}),
  ('regression duration blocks #2',
   [{'price': 10, 'hours': 48, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression duration blocks #3',
   [{'price': 50, 'hours': 24, 'stack_value': 6}, {'status': 'expired'}],
   {'deposit': 2, 'net': -2}),
  ('fault site duration blocks #1',
   [{'price': 11, 'hours': 12, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 1, 'net': -1}),
  ('fault site duration blocks #2',
   [{'price': 1, 'hours': 12, 'stack_value': 4743}, {'status': 'cancelled', 'bid': 0}],
   {'deposit': 711, 'net': -711})],
 [('half-up cut boundary #1',
   [{'price': 10, 'hours': 12, 'stack_value': 100}, {'status': 'sold'}],
   {'deposit': 15, 'net': 9}),
  ('cancel with bid #1',
   [{'price': 500, 'hours': 24, 'stack_value': 40}, {'status': 'cancelled', 'bid': 390}],
   {'deposit': 12, 'net': -31}),
  ('regression duration blocks #1',
   [{'price': 11, 'hours': 24, 'stack_value': 13}, {'status': 'cancelled', 'bid': 0}],
   {'deposit': 2, 'net': -2}),
  ('regression duration blocks #2',
   [{'price': 10, 'hours': 48, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression duration blocks #3',
   [{'price': 50, 'hours': 24, 'stack_value': 6}, {'status': 'expired'}],
   {'deposit': 2, 'net': -2}),
  ('regression duration blocks #4',
   [{'price': 190, 'hours': 24, 'stack_value': 13}, {'status': 'expired'}],
   {'deposit': 2, 'net': -2}),
  ('fault site duration blocks #1',
   [{'price': 11, 'hours': 12, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 1, 'net': -1}),
  ('fault site duration blocks #2',
   [{'price': 1, 'hours': 12, 'stack_value': 4743}, {'status': 'cancelled', 'bid': 0}],
   {'deposit': 711, 'net': -711})],
 [('cancel with bid #1',
   [{'price': 500, 'hours': 24, 'stack_value': 40}, {'status': 'cancelled', 'bid': 390}],
   {'deposit': 12, 'net': -31}),
  ('long cheap listing #1',
   [{'price': 10, 'hours': 48, 'stack_value': 3}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression duration blocks #1',
   [{'price': 10, 'hours': 48, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression duration blocks #2',
   [{'price': 50, 'hours': 24, 'stack_value': 6}, {'status': 'expired'}],
   {'deposit': 2, 'net': -2}),
  ('regression duration blocks #3',
   [{'price': 190, 'hours': 24, 'stack_value': 13}, {'status': 'expired'}],
   {'deposit': 2, 'net': -2}),
  ('regression duration blocks #4',
   [{'price': 912, 'hours': 24, 'stack_value': 0}, {'status': 'cancelled'}],
   {'deposit': 2, 'net': -2}),
  ('fault site duration blocks #1',
   [{'price': 11, 'hours': 12, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 1, 'net': -1}),
  ('fault site duration blocks #2',
   [{'price': 1, 'hours': 12, 'stack_value': 4743}, {'status': 'cancelled', 'bid': 0}],
   {'deposit': 711, 'net': -711})],
 [('long cheap listing #1',
   [{'price': 10, 'hours': 48, 'stack_value': 3}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('cancel with bid #1',
   [{'price': 500, 'hours': 24, 'stack_value': 40}, {'status': 'cancelled', 'bid': 390}],
   {'deposit': 12, 'net': -31}),
  ('fault site duration blocks #1',
   [{'price': 11, 'hours': 12, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 1, 'net': -1}),
  ('fault site duration blocks #2',
   [{'price': 1, 'hours': 12, 'stack_value': 4743}, {'status': 'cancelled', 'bid': 0}],
   {'deposit': 711, 'net': -711}),
  ('regression duration blocks #1',
   [{'price': 912, 'hours': 24, 'stack_value': 0}, {'status': 'cancelled'}],
   {'deposit': 2, 'net': -2}),
  ('regression duration blocks #2',
   [{'price': 190, 'hours': 48, 'stack_value': 0}, {'status': 'cancelled', 'bid': 99}],
   {'deposit': 4, 'net': -8}),
  ('regression duration blocks #3',
   [{'price': 190, 'hours': 24, 'stack_value': 13}, {'status': 'expired'}],
   {'deposit': 2, 'net': -2}),
  ('fault site duration blocks #3',
   [{'price': 190, 'hours': 12, 'stack_value': 13}, {'status': 'cancelled'}],
   {'deposit': 1, 'net': -1})],
 [('half-up cut boundary #1',
   [{'price': 10, 'hours': 12, 'stack_value': 100}, {'status': 'sold'}],
   {'deposit': 15, 'net': 9}),
  ('long cheap listing #1',
   [{'price': 10, 'hours': 48, 'stack_value': 3}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression duration blocks #1',
   [{'price': 190, 'hours': 24, 'stack_value': 13}, {'status': 'expired'}],
   {'deposit': 2, 'net': -2}),
  ('fault site duration blocks #1',
   [{'price': 190, 'hours': 12, 'stack_value': 13}, {'status': 'cancelled'}],
   {'deposit': 1, 'net': -1}),
  ('regression duration blocks #2',
   [{'price': 1, 'hours': 24, 'stack_value': 7}, {'status': 'sold'}],
   {'deposit': 2, 'net': 1}),
  ('regression duration blocks #3',
   [{'price': 30, 'hours': 48, 'stack_value': 7}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('fault site duration blocks #2',
   [{'price': 10, 'hours': 12, 'stack_value': 0}, {'status': 'cancelled', 'bid': 99}],
   {'deposit': 1, 'net': -5}),
  ('regression duration blocks #4',
   [{'price': 912, 'hours': 24, 'stack_value': 0}, {'status': 'cancelled'}],
   {'deposit': 2, 'net': -2})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(listing, outcome):
    blocks = max(1, listing['hours'] // 24)
    per_block = max(1, listing['stack_value'] * 15 // 100)
    deposit = per_block * blocks
    status = outcome['status']
    if status == 'sold':
        cut = (listing['price'] * 5 + 50) // 100
        net = listing['price'] - cut
    elif status == 'cancelled':
        net = -deposit - outcome.get('bid', 0) * 5 // 100
    else:
        net = -deposit
    return {'deposit': deposit, 'net': net}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('long cheap listing #1',
   [{'price': 10, 'hours': 48, 'stack_value': 3}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('cancel with bid #1',
   [{'price': 500, 'hours': 24, 'stack_value': 40}, {'status': 'cancelled', 'bid': 390}],
   {'deposit': 12, 'net': -31}),
  ('half-up cut boundary #1',
   [{'price': 10, 'hours': 12, 'stack_value': 100}, {'status': 'sold'}],
   {'deposit': 15, 'net': 9}),
  ('regression duration blocks #1',
   [{'price': 11, 'hours': 24, 'stack_value': 13}, {'status': 'cancelled', 'bid': 0}],
   {'deposit': 2, 'net': -2}),
  ('regression duration blocks #2',
   [{'price': 10, 'hours': 48, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression duration blocks #3',
   [{'price': 50, 'hours': 24, 'stack_value': 6}, {'status': 'expired'}],
   {'deposit': 2, 'net': -2}),
  ('fault site duration blocks #1',
   [{'price': 11, 'hours': 12, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 1, 'net': -1}),
  ('fault site duration blocks #2',
   [{'price': 1, 'hours': 12, 'stack_value': 4743}, {'status': 'cancelled', 'bid': 0}],
   {'deposit': 711, 'net': -711})],
 [('half-up cut boundary #1',
   [{'price': 10, 'hours': 12, 'stack_value': 100}, {'status': 'sold'}],
   {'deposit': 15, 'net': 9}),
  ('cancel with bid #1',
   [{'price': 500, 'hours': 24, 'stack_value': 40}, {'status': 'cancelled', 'bid': 390}],
   {'deposit': 12, 'net': -31}),
  ('regression duration blocks #1',
   [{'price': 11, 'hours': 24, 'stack_value': 13}, {'status': 'cancelled', 'bid': 0}],
   {'deposit': 2, 'net': -2}),
  ('regression duration blocks #2',
   [{'price': 10, 'hours': 48, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression duration blocks #3',
   [{'price': 50, 'hours': 24, 'stack_value': 6}, {'status': 'expired'}],
   {'deposit': 2, 'net': -2}),
  ('regression duration blocks #4',
   [{'price': 190, 'hours': 24, 'stack_value': 13}, {'status': 'expired'}],
   {'deposit': 2, 'net': -2}),
  ('fault site duration blocks #1',
   [{'price': 11, 'hours': 12, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 1, 'net': -1}),
  ('fault site duration blocks #2',
   [{'price': 1, 'hours': 12, 'stack_value': 4743}, {'status': 'cancelled', 'bid': 0}],
   {'deposit': 711, 'net': -711})],
 [('cancel with bid #1',
   [{'price': 500, 'hours': 24, 'stack_value': 40}, {'status': 'cancelled', 'bid': 390}],
   {'deposit': 12, 'net': -31}),
  ('long cheap listing #1',
   [{'price': 10, 'hours': 48, 'stack_value': 3}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression duration blocks #1',
   [{'price': 10, 'hours': 48, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression duration blocks #2',
   [{'price': 50, 'hours': 24, 'stack_value': 6}, {'status': 'expired'}],
   {'deposit': 2, 'net': -2}),
  ('regression duration blocks #3',
   [{'price': 190, 'hours': 24, 'stack_value': 13}, {'status': 'expired'}],
   {'deposit': 2, 'net': -2}),
  ('regression duration blocks #4',
   [{'price': 912, 'hours': 24, 'stack_value': 0}, {'status': 'cancelled'}],
   {'deposit': 2, 'net': -2}),
  ('fault site duration blocks #1',
   [{'price': 11, 'hours': 12, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 1, 'net': -1}),
  ('fault site duration blocks #2',
   [{'price': 1, 'hours': 12, 'stack_value': 4743}, {'status': 'cancelled', 'bid': 0}],
   {'deposit': 711, 'net': -711})],
 [('long cheap listing #1',
   [{'price': 10, 'hours': 48, 'stack_value': 3}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('cancel with bid #1',
   [{'price': 500, 'hours': 24, 'stack_value': 40}, {'status': 'cancelled', 'bid': 390}],
   {'deposit': 12, 'net': -31}),
  ('fault site duration blocks #1',
   [{'price': 11, 'hours': 12, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 1, 'net': -1}),
  ('fault site duration blocks #2',
   [{'price': 1, 'hours': 12, 'stack_value': 4743}, {'status': 'cancelled', 'bid': 0}],
   {'deposit': 711, 'net': -711}),
  ('regression duration blocks #1',
   [{'price': 912, 'hours': 24, 'stack_value': 0}, {'status': 'cancelled'}],
   {'deposit': 2, 'net': -2}),
  ('regression duration blocks #2',
   [{'price': 190, 'hours': 48, 'stack_value': 0}, {'status': 'cancelled', 'bid': 99}],
   {'deposit': 4, 'net': -8}),
  ('regression duration blocks #3',
   [{'price': 190, 'hours': 24, 'stack_value': 13}, {'status': 'expired'}],
   {'deposit': 2, 'net': -2}),
  ('fault site duration blocks #3',
   [{'price': 190, 'hours': 12, 'stack_value': 13}, {'status': 'cancelled'}],
   {'deposit': 1, 'net': -1})],
 [('half-up cut boundary #1',
   [{'price': 10, 'hours': 12, 'stack_value': 100}, {'status': 'sold'}],
   {'deposit': 15, 'net': 9}),
  ('long cheap listing #1',
   [{'price': 10, 'hours': 48, 'stack_value': 3}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression duration blocks #1',
   [{'price': 190, 'hours': 24, 'stack_value': 13}, {'status': 'expired'}],
   {'deposit': 2, 'net': -2}),
  ('fault site duration blocks #1',
   [{'price': 190, 'hours': 12, 'stack_value': 13}, {'status': 'cancelled'}],
   {'deposit': 1, 'net': -1}),
  ('regression duration blocks #2',
   [{'price': 1, 'hours': 24, 'stack_value': 7}, {'status': 'sold'}],
   {'deposit': 2, 'net': 1}),
  ('regression duration blocks #3',
   [{'price': 30, 'hours': 48, 'stack_value': 7}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('fault site duration blocks #2',
   [{'price': 10, 'hours': 12, 'stack_value': 0}, {'status': 'cancelled', 'bid': 99}],
   {'deposit': 1, 'net': -5}),
  ('regression duration blocks #4',
   [{'price': 912, 'hours': 24, 'stack_value': 0}, {'status': 'cancelled'}],
   {'deposit': 2, 'net': -2})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Long listings are undercharged by half.

Deposit = per_block * (hours//12) where per_block = max(1, floor(stack_value*15/100)). Sold: net = price - cut with cut = 5% of price rounded half up (deposit refunded). Expired: net = -deposit. Cancelled: net = -deposit - floor(bid*5/100) (bid defaults to 0). Returns {deposit, net} in copper.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(listing, outcome):
    blocks = listing['hours'] // 12
    per_block = listing['stack_value'] * 15 // 100
    deposit = per_block * blocks
    status = outcome['status']
    if status == 'sold':
        cut = (listing['price'] * 5 + 50) // 100
        net = listing['price'] - cut
    elif status == 'cancelled':
        net = -deposit - outcome.get('bid', 0) * 5 // 100
    else:
        net = -deposit
    return {'deposit': deposit, 'net': net}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('long cheap listing #1',
   [{'price': 10, 'hours': 48, 'stack_value': 3}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression per-block minimum #1',
   [{'price': 10, 'hours': 48, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression per-block minimum #2',
   [{'price': 50, 'hours': 24, 'stack_value': 6}, {'status': 'expired'}],
   {'deposit': 2, 'net': -2}),
  ('regression per-block minimum #3',
   [{'price': 11, 'hours': 12, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 1, 'net': -1}),
  ('regression per-block minimum #4',
   [{'price': 10, 'hours': 12, 'stack_value': 0}, {'status': 'cancelled', 'bid': 99}],
   {'deposit': 1, 'net': -5}),
  ('half-up cut boundary #1',
   [{'price': 10, 'hours': 12, 'stack_value': 100}, {'status': 'sold'}],
   {'deposit': 15, 'net': 9}),
  ('cancel with bid #1',
   [{'price': 500, 'hours': 24, 'stack_value': 40}, {'status': 'cancelled', 'bid': 390}],
   {'deposit': 12, 'net': -31}),
  ('control #1',
   [{'price': 11, 'hours': 24, 'stack_value': 13}, {'status': 'cancelled', 'bid': 0}],
   {'deposit': 2, 'net': -2})],
 [('long cheap listing #1',
   [{'price': 10, 'hours': 48, 'stack_value': 3}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression per-block minimum #1',
   [{'price': 50, 'hours': 24, 'stack_value': 6}, {'status': 'expired'}],
   {'deposit': 2, 'net': -2}),
  ('regression per-block minimum #2',
   [{'price': 11, 'hours': 12, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 1, 'net': -1}),
  ('regression per-block minimum #3',
   [{'price': 10, 'hours': 12, 'stack_value': 0}, {'status': 'cancelled', 'bid': 99}],
   {'deposit': 1, 'net': -5}),
  ('regression per-block minimum #4',
   [{'price': 912, 'hours': 24, 'stack_value': 0}, {'status': 'cancelled'}],
   {'deposit': 2, 'net': -2}),
  ('half-up cut boundary #1',
   [{'price': 10, 'hours': 12, 'stack_value': 100}, {'status': 'sold'}],
   {'deposit': 15, 'net': 9}),
  ('cancel with bid #1',
   [{'price': 500, 'hours': 24, 'stack_value': 40}, {'status': 'cancelled', 'bid': 390}],
   {'deposit': 12, 'net': -31}),
  ('control #1',
   [{'price': 11, 'hours': 24, 'stack_value': 13}, {'status': 'cancelled', 'bid': 0}],
   {'deposit': 2, 'net': -2})],
 [('long cheap listing #1',
   [{'price': 10, 'hours': 48, 'stack_value': 3}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression per-block minimum #1',
   [{'price': 10, 'hours': 12, 'stack_value': 0}, {'status': 'cancelled', 'bid': 99}],
   {'deposit': 1, 'net': -5}),
  ('regression per-block minimum #2',
   [{'price': 912, 'hours': 24, 'stack_value': 0}, {'status': 'cancelled'}],
   {'deposit': 2, 'net': -2}),
  ('regression per-block minimum #3',
   [{'price': 190, 'hours': 48, 'stack_value': 0}, {'status': 'cancelled', 'bid': 99}],
   {'deposit': 4, 'net': -8}),
  ('regression per-block minimum #4',
   [{'price': 30, 'hours': 12, 'stack_value': 6}, {'status': 'sold'}],
   {'deposit': 1, 'net': 28}),
  ('half-up cut boundary #1',
   [{'price': 10, 'hours': 12, 'stack_value': 100}, {'status': 'sold'}],
   {'deposit': 15, 'net': 9}),
  ('cancel with bid #1',
   [{'price': 500, 'hours': 24, 'stack_value': 40}, {'status': 'cancelled', 'bid': 390}],
   {'deposit': 12, 'net': -31}),
  ('control #1',
   [{'price': 11, 'hours': 24, 'stack_value': 13}, {'status': 'cancelled', 'bid': 0}],
   {'deposit': 2, 'net': -2})],
 [('long cheap listing #1',
   [{'price': 10, 'hours': 48, 'stack_value': 3}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression per-block minimum #1',
   [{'price': 190, 'hours': 48, 'stack_value': 0}, {'status': 'cancelled', 'bid': 99}],
   {'deposit': 4, 'net': -8}),
  ('regression per-block minimum #2',
   [{'price': 30, 'hours': 12, 'stack_value': 6}, {'status': 'sold'}],
   {'deposit': 1, 'net': 28}),
  ('regression per-block minimum #3',
   [{'price': 30, 'hours': 48, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression per-block minimum #4',
   [{'price': 190, 'hours': 12, 'stack_value': 0}, {'status': 'sold'}],
   {'deposit': 1, 'net': 180}),
  ('half-up cut boundary #1',
   [{'price': 10, 'hours': 12, 'stack_value': 100}, {'status': 'sold'}],
   {'deposit': 15, 'net': 9}),
  ('cancel with bid #1',
   [{'price': 500, 'hours': 24, 'stack_value': 40}, {'status': 'cancelled', 'bid': 390}],
   {'deposit': 12, 'net': -31}),
  ('control #1',
   [{'price': 1, 'hours': 12, 'stack_value': 4743}, {'status': 'cancelled', 'bid': 0}],
   {'deposit': 711, 'net': -711})],
 [('long cheap listing #1',
   [{'price': 10, 'hours': 48, 'stack_value': 3}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression per-block minimum #1',
   [{'price': 30, 'hours': 48, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression per-block minimum #2',
   [{'price': 190, 'hours': 12, 'stack_value': 0}, {'status': 'sold'}],
   {'deposit': 1, 'net': 180}),
  ('regression per-block minimum #3',
   [{'price': 66296, 'hours': 48, 'stack_value': 1}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression per-block minimum #4',
   [{'price': 30, 'hours': 12, 'stack_value': 1}, {'status': 'expired'}],
   {'deposit': 1, 'net': -1}),
  ('half-up cut boundary #1',
   [{'price': 10, 'hours': 12, 'stack_value': 100}, {'status': 'sold'}],
   {'deposit': 15, 'net': 9}),
  ('cancel with bid #1',
   [{'price': 500, 'hours': 24, 'stack_value': 40}, {'status': 'cancelled', 'bid': 390}],
   {'deposit': 12, 'net': -31}),
  ('control #1',
   [{'price': 190, 'hours': 24, 'stack_value': 13}, {'status': 'expired'}],
   {'deposit': 2, 'net': -2})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(listing, outcome):
    blocks = listing['hours'] // 12
    per_block = max(1, listing['stack_value']) * 15 // 100
    deposit = per_block * blocks
    status = outcome['status']
    if status == 'sold':
        cut = (listing['price'] * 5 + 50) // 100
        net = listing['price'] - cut
    elif status == 'cancelled':
        net = -deposit - outcome.get('bid', 0) * 5 // 100
    else:
        net = -deposit
    return {'deposit': deposit, 'net': net}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('long cheap listing #1',
   [{'price': 10, 'hours': 48, 'stack_value': 3}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression per-block minimum #1',
   [{'price': 10, 'hours': 48, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression per-block minimum #2',
   [{'price': 50, 'hours': 24, 'stack_value': 6}, {'status': 'expired'}],
   {'deposit': 2, 'net': -2}),
  ('regression per-block minimum #3',
   [{'price': 11, 'hours': 12, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 1, 'net': -1}),
  ('regression per-block minimum #4',
   [{'price': 10, 'hours': 12, 'stack_value': 0}, {'status': 'cancelled', 'bid': 99}],
   {'deposit': 1, 'net': -5}),
  ('half-up cut boundary #1',
   [{'price': 10, 'hours': 12, 'stack_value': 100}, {'status': 'sold'}],
   {'deposit': 15, 'net': 9}),
  ('cancel with bid #1',
   [{'price': 500, 'hours': 24, 'stack_value': 40}, {'status': 'cancelled', 'bid': 390}],
   {'deposit': 12, 'net': -31}),
  ('control #1',
   [{'price': 11, 'hours': 24, 'stack_value': 13}, {'status': 'cancelled', 'bid': 0}],
   {'deposit': 2, 'net': -2})],
 [('long cheap listing #1',
   [{'price': 10, 'hours': 48, 'stack_value': 3}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression per-block minimum #1',
   [{'price': 50, 'hours': 24, 'stack_value': 6}, {'status': 'expired'}],
   {'deposit': 2, 'net': -2}),
  ('regression per-block minimum #2',
   [{'price': 11, 'hours': 12, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 1, 'net': -1}),
  ('regression per-block minimum #3',
   [{'price': 10, 'hours': 12, 'stack_value': 0}, {'status': 'cancelled', 'bid': 99}],
   {'deposit': 1, 'net': -5}),
  ('regression per-block minimum #4',
   [{'price': 912, 'hours': 24, 'stack_value': 0}, {'status': 'cancelled'}],
   {'deposit': 2, 'net': -2}),
  ('half-up cut boundary #1',
   [{'price': 10, 'hours': 12, 'stack_value': 100}, {'status': 'sold'}],
   {'deposit': 15, 'net': 9}),
  ('cancel with bid #1',
   [{'price': 500, 'hours': 24, 'stack_value': 40}, {'status': 'cancelled', 'bid': 390}],
   {'deposit': 12, 'net': -31}),
  ('control #1',
   [{'price': 11, 'hours': 24, 'stack_value': 13}, {'status': 'cancelled', 'bid': 0}],
   {'deposit': 2, 'net': -2})],
 [('long cheap listing #1',
   [{'price': 10, 'hours': 48, 'stack_value': 3}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression per-block minimum #1',
   [{'price': 10, 'hours': 12, 'stack_value': 0}, {'status': 'cancelled', 'bid': 99}],
   {'deposit': 1, 'net': -5}),
  ('regression per-block minimum #2',
   [{'price': 912, 'hours': 24, 'stack_value': 0}, {'status': 'cancelled'}],
   {'deposit': 2, 'net': -2}),
  ('regression per-block minimum #3',
   [{'price': 190, 'hours': 48, 'stack_value': 0}, {'status': 'cancelled', 'bid': 99}],
   {'deposit': 4, 'net': -8}),
  ('regression per-block minimum #4',
   [{'price': 30, 'hours': 12, 'stack_value': 6}, {'status': 'sold'}],
   {'deposit': 1, 'net': 28}),
  ('half-up cut boundary #1',
   [{'price': 10, 'hours': 12, 'stack_value': 100}, {'status': 'sold'}],
   {'deposit': 15, 'net': 9}),
  ('cancel with bid #1',
   [{'price': 500, 'hours': 24, 'stack_value': 40}, {'status': 'cancelled', 'bid': 390}],
   {'deposit': 12, 'net': -31}),
  ('control #1',
   [{'price': 11, 'hours': 24, 'stack_value': 13}, {'status': 'cancelled', 'bid': 0}],
   {'deposit': 2, 'net': -2})],
 [('long cheap listing #1',
   [{'price': 10, 'hours': 48, 'stack_value': 3}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression per-block minimum #1',
   [{'price': 190, 'hours': 48, 'stack_value': 0}, {'status': 'cancelled', 'bid': 99}],
   {'deposit': 4, 'net': -8}),
  ('regression per-block minimum #2',
   [{'price': 30, 'hours': 12, 'stack_value': 6}, {'status': 'sold'}],
   {'deposit': 1, 'net': 28}),
  ('regression per-block minimum #3',
   [{'price': 30, 'hours': 48, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression per-block minimum #4',
   [{'price': 190, 'hours': 12, 'stack_value': 0}, {'status': 'sold'}],
   {'deposit': 1, 'net': 180}),
  ('half-up cut boundary #1',
   [{'price': 10, 'hours': 12, 'stack_value': 100}, {'status': 'sold'}],
   {'deposit': 15, 'net': 9}),
  ('cancel with bid #1',
   [{'price': 500, 'hours': 24, 'stack_value': 40}, {'status': 'cancelled', 'bid': 390}],
   {'deposit': 12, 'net': -31}),
  ('control #1',
   [{'price': 1, 'hours': 12, 'stack_value': 4743}, {'status': 'cancelled', 'bid': 0}],
   {'deposit': 711, 'net': -711})],
 [('long cheap listing #1',
   [{'price': 10, 'hours': 48, 'stack_value': 3}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression per-block minimum #1',
   [{'price': 30, 'hours': 48, 'stack_value': 0}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression per-block minimum #2',
   [{'price': 190, 'hours': 12, 'stack_value': 0}, {'status': 'sold'}],
   {'deposit': 1, 'net': 180}),
  ('regression per-block minimum #3',
   [{'price': 66296, 'hours': 48, 'stack_value': 1}, {'status': 'expired'}],
   {'deposit': 4, 'net': -4}),
  ('regression per-block minimum #4',
   [{'price': 30, 'hours': 12, 'stack_value': 1}, {'status': 'expired'}],
   {'deposit': 1, 'net': -1}),
  ('half-up cut boundary #1',
   [{'price': 10, 'hours': 12, 'stack_value': 100}, {'status': 'sold'}],
   {'deposit': 15, 'net': 9}),
  ('cancel with bid #1',
   [{'price': 500, 'hours': 24, 'stack_value': 40}, {'status': 'cancelled', 'bid': 390}],
   {'deposit': 12, 'net': -31}),
  ('control #1',
   [{'price': 190, 'hours': 24, 'stack_value': 13}, {'status': 'expired'}],
   {'deposit': 2, 'net': -2})]]
for label, args, expected in cases[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Low-value items pay no deposit and flood the auction house.

Deposit = per_block * (hours//12) where per_block = max(1, floor(stack_value*15/100)). Sold: net = price - cut with cut = 5% of price rounded half up (deposit refunded). Expired: net = -deposit. Cancelled: net = -deposit - floor(bid*5/100) (bid defaults to 0). Returns {deposit, net} in copper.

split: open-access