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

N = 1
observations = []
def solve(item, components):
    pct = {'common': 50, 'rare': 70, 'epic': 90}[item['rarity']]
    mx = item['max_durability']
    if mx == 0:
        d, mx = 0, 1
    else:
        d = min(item['durability'], mx)
    if d <= 0:
        return {'scrap': 1}
    out = {}
    for name, count in components.items():
        amt = count * pct * d // (100 * mx)
        if item['rarity'] != 'common' and amt < 1:
            amt = 1
        if amt:
            out[name] = amt
    return dict(sorted(out.items()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('fault site indestructible condition #1',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 0}, {'cloth': 5, 'ingot': 4, 'shard': 1}],
   {'cloth': 3, 'ingot': 2, 'shard': 1}),
  ('fault site indestructible condition #2',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 0}, {'shard': 2, 'ingot': 2, 'thread': 6}],
   {'ingot': 1, 'shard': 1, 'thread': 3}),
  ('regression indestructible condition #1',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 0}, {'thread': 6, 'shard': 4}],
   {'shard': 2, 'thread': 3}),
  ('regression indestructible condition #2',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 0}, {'cloth': 6}],
   {'cloth': 3}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {})],
 [('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('fault site indestructible condition #1',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 0}, {'shard': 2, 'ingot': 2, 'thread': 6}],
   {'ingot': 1, 'shard': 1, 'thread': 3}),
  ('fault site indestructible condition #2',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 0}, {'cloth': 6, 'ingot': 2}],
   {'cloth': 3, 'ingot': 1}),
  ('regression indestructible condition #1',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 0}, {'cloth': 6}],
   {'cloth': 3}),
  ('regression indestructible condition #2',
   [{'rarity': 'rare', 'durability': 5, 'max_durability': 0}, {'cloth': 3, 'ingot': 6, 'shard': 3}],
   {'cloth': 2, 'ingot': 4, 'shard': 2}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {})],
 [('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('regression indestructible condition #1',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 0}, {'thread': 6, 'shard': 4}],
   {'shard': 2, 'thread': 3}),
  ('fault site indestructible condition #1',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 0}, {'cloth': 6, 'ingot': 6}],
   {'cloth': 3, 'ingot': 3}),
  ('regression indestructible condition #2',
   [{'rarity': 'rare', 'durability': 5, 'max_durability': 0}, {'thread': 6, 'cloth': 1, 'shard': 3}],
   {'cloth': 1, 'shard': 2, 'thread': 4}),
  ('regression indestructible condition #3',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5, 'cloth': 5, 'thread': 3}],
   {'cloth': 4, 'shard': 4, 'thread': 2}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {})],
 [('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('fault site indestructible condition #1',
   [{'rarity': 'epic', 'durability': 1, 'max_durability': 0}, {'shard': 3, 'ingot': 4}],
   {'ingot': 3, 'shard': 2}),
  ('regression indestructible condition #1',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 0}, {'cloth': 6}],
   {'cloth': 3}),
  ('regression indestructible condition #2',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 0}, {'thread': 5, 'ingot': 6}],
   {'ingot': 3, 'thread': 2}),
  ('regression indestructible condition #3',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 0}, {'shard': 2, 'ingot': 5}],
   {'ingot': 3, 'shard': 1}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1', [{'rarity': 'rare', 'durability': 0, 'max_durability': 100}, {'shard': 5}], {'scrap': 1})],
 [('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('regression indestructible condition #1',
   [{'rarity': 'rare', 'durability': 5, 'max_durability': 0}, {'cloth': 3, 'ingot': 6, 'shard': 3}],
   {'cloth': 2, 'ingot': 4, 'shard': 2}),
  ('regression indestructible condition #2',
   [{'rarity': 'rare', 'durability': 5, 'max_durability': 0}, {'thread': 6, 'cloth': 1, 'shard': 3}],
   {'cloth': 1, 'shard': 2, 'thread': 4}),
  ('regression indestructible condition #3',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'cloth': 6, 'thread': 4, 'ingot': 5}],
   {'cloth': 5, 'ingot': 4, 'thread': 3}),
  ('regression indestructible condition #4',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 0}, {'thread': 4}],
   {'thread': 2}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 100}, {'cloth': 6, 'thread': 1}],
   {'scrap': 1})]]
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(item, components):
    pct = {'common': 50, 'rare': 70, 'epic': 90}[item['rarity']]
    mx = item['max_durability']
    if mx == 0:
        d, mx = item['durability'], 1
    else:
        d = min(item['durability'], mx)
    if d <= 0:
        return {'scrap': 1}
    out = {}
    for name, count in components.items():
        amt = count * pct * d // (100 * mx)
        if item['rarity'] != 'common' and amt < 1:
            amt = 1
        if amt:
            out[name] = amt
    return dict(sorted(out.items()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('fault site indestructible condition #1',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 0}, {'cloth': 5, 'ingot': 4, 'shard': 1}],
   {'cloth': 3, 'ingot': 2, 'shard': 1}),
  ('fault site indestructible condition #2',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 0}, {'shard': 2, 'ingot': 2, 'thread': 6}],
   {'ingot': 1, 'shard': 1, 'thread': 3}),
  ('regression indestructible condition #1',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 0}, {'thread': 6, 'shard': 4}],
   {'shard': 2, 'thread': 3}),
  ('regression indestructible condition #2',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 0}, {'cloth': 6}],
   {'cloth': 3}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {})],
 [('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('fault site indestructible condition #1',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 0}, {'shard': 2, 'ingot': 2, 'thread': 6}],
   {'ingot': 1, 'shard': 1, 'thread': 3}),
  ('fault site indestructible condition #2',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 0}, {'cloth': 6, 'ingot': 2}],
   {'cloth': 3, 'ingot': 1}),
  ('regression indestructible condition #1',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 0}, {'cloth': 6}],
   {'cloth': 3}),
  ('regression indestructible condition #2',
   [{'rarity': 'rare', 'durability': 5, 'max_durability': 0}, {'cloth': 3, 'ingot': 6, 'shard': 3}],
   {'cloth': 2, 'ingot': 4, 'shard': 2}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {})],
 [('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('regression indestructible condition #1',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 0}, {'thread': 6, 'shard': 4}],
   {'shard': 2, 'thread': 3}),
  ('fault site indestructible condition #1',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 0}, {'cloth': 6, 'ingot': 6}],
   {'cloth': 3, 'ingot': 3}),
  ('regression indestructible condition #2',
   [{'rarity': 'rare', 'durability': 5, 'max_durability': 0}, {'thread': 6, 'cloth': 1, 'shard': 3}],
   {'cloth': 1, 'shard': 2, 'thread': 4}),
  ('regression indestructible condition #3',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5, 'cloth': 5, 'thread': 3}],
   {'cloth': 4, 'shard': 4, 'thread': 2}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {})],
 [('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('fault site indestructible condition #1',
   [{'rarity': 'epic', 'durability': 1, 'max_durability': 0}, {'shard': 3, 'ingot': 4}],
   {'ingot': 3, 'shard': 2}),
  ('regression indestructible condition #1',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 0}, {'cloth': 6}],
   {'cloth': 3}),
  ('regression indestructible condition #2',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 0}, {'thread': 5, 'ingot': 6}],
   {'ingot': 3, 'thread': 2}),
  ('regression indestructible condition #3',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 0}, {'shard': 2, 'ingot': 5}],
   {'ingot': 3, 'shard': 1}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1', [{'rarity': 'rare', 'durability': 0, 'max_durability': 100}, {'shard': 5}], {'scrap': 1})],
 [('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('regression indestructible condition #1',
   [{'rarity': 'rare', 'durability': 5, 'max_durability': 0}, {'cloth': 3, 'ingot': 6, 'shard': 3}],
   {'cloth': 2, 'ingot': 4, 'shard': 2}),
  ('regression indestructible condition #2',
   [{'rarity': 'rare', 'durability': 5, 'max_durability': 0}, {'thread': 6, 'cloth': 1, 'shard': 3}],
   {'cloth': 1, 'shard': 2, 'thread': 4}),
  ('regression indestructible condition #3',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'cloth': 6, 'thread': 4, 'ingot': 5}],
   {'cloth': 5, 'ingot': 4, 'thread': 3}),
  ('regression indestructible condition #4',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 0}, {'thread': 4}],
   {'thread': 2}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 100}, {'cloth': 6, 'thread': 1}],
   {'scrap': 1})]]
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:
Relics without durability are treated as broken and return only scrap.

Return rate: common 50%, rare 70%, epic 90%. Condition d/mx with d clamped to mx; max_durability 0 means indestructible (full condition). Durability <= 0 yields {"scrap": 1}. Each component amount = floor(count*pct*d/(100*mx)) computed once; rare and epic items return at least 1 of each component; zero amounts are omitted.

split: open-access


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

N = 1
observations = []
def solve(item, components):
    pct = {'common': 50, 'rare': 70, 'epic': 90}[item['rarity']]
    mx = item['max_durability']
    if mx == 0:
        d, mx = 1, 1
    else:
        d = item['durability']
    if d <= 0:
        return {'scrap': 1}
    out = {}
    for name, count in components.items():
        amt = count * pct * d // (100 * mx)
        if item['rarity'] != 'common' and amt < 1:
            amt = 1
        if amt:
            out[name] = amt
    return dict(sorted(out.items()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('regression over-repair clamp #1',
   [{'rarity': 'epic', 'durability': 12, 'max_durability': 7}, {'ingot': 5}],
   {'ingot': 4}),
  ('regression over-repair clamp #2',
   [{'rarity': 'rare', 'durability': 12, 'max_durability': 7}, {'cloth': 3}],
   {'cloth': 2}),
  ('regression over-repair clamp #3',
   [{'rarity': 'epic', 'durability': 12, 'max_durability': 7}, {'thread': 4, 'ingot': 5}],
   {'ingot': 4, 'thread': 3}),
  ('regression over-repair clamp #4',
   [{'rarity': 'rare', 'durability': 15, 'max_durability': 10}, {'thread': 2, 'ingot': 3, 'shard': 2}],
   {'ingot': 2, 'shard': 1, 'thread': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {})],
 [('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('regression over-repair clamp #1',
   [{'rarity': 'rare', 'durability': 12, 'max_durability': 7}, {'cloth': 3}],
   {'cloth': 2}),
  ('regression over-repair clamp #2',
   [{'rarity': 'epic', 'durability': 12, 'max_durability': 7}, {'thread': 4, 'ingot': 5}],
   {'ingot': 4, 'thread': 3}),
  ('regression over-repair clamp #3',
   [{'rarity': 'rare', 'durability': 15, 'max_durability': 10}, {'thread': 2, 'ingot': 3, 'shard': 2}],
   {'ingot': 2, 'shard': 1, 'thread': 1}),
  ('regression over-repair clamp #4',
   [{'rarity': 'epic', 'durability': 25, 'max_durability': 20}, {'ingot': 6}],
   {'ingot': 5}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {})],
 [('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('regression over-repair clamp #1',
   [{'rarity': 'rare', 'durability': 15, 'max_durability': 10}, {'thread': 2, 'ingot': 3, 'shard': 2}],
   {'ingot': 2, 'shard': 1, 'thread': 1}),
  ('regression over-repair clamp #2',
   [{'rarity': 'epic', 'durability': 25, 'max_durability': 20}, {'ingot': 6}],
   {'ingot': 5}),
  ('regression over-repair clamp #3',
   [{'rarity': 'rare', 'durability': 25, 'max_durability': 20}, {'ingot': 5, 'thread': 2, 'shard': 1}],
   {'ingot': 3, 'shard': 1, 'thread': 1}),
  ('regression over-repair clamp #4',
   [{'rarity': 'epic', 'durability': 15, 'max_durability': 10}, {'shard': 6}],
   {'shard': 5}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {})],
 [('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('regression over-repair clamp #1',
   [{'rarity': 'rare', 'durability': 25, 'max_durability': 20}, {'ingot': 5, 'thread': 2, 'shard': 1}],
   {'ingot': 3, 'shard': 1, 'thread': 1}),
  ('regression over-repair clamp #2',
   [{'rarity': 'epic', 'durability': 15, 'max_durability': 10}, {'shard': 6}],
   {'shard': 5}),
  ('regression over-repair clamp #3',
   [{'rarity': 'rare', 'durability': 25, 'max_durability': 20}, {'shard': 4, 'thread': 2, 'ingot': 1}],
   {'ingot': 1, 'shard': 2, 'thread': 1}),
  ('regression over-repair clamp #4',
   [{'rarity': 'epic', 'durability': 25, 'max_durability': 20}, {'shard': 5, 'cloth': 3}],
   {'cloth': 2, 'shard': 4}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1', [{'rarity': 'rare', 'durability': 0, 'max_durability': 100}, {'shard': 5}], {'scrap': 1})],
 [('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('regression over-repair clamp #1',
   [{'rarity': 'rare', 'durability': 25, 'max_durability': 20}, {'shard': 4, 'thread': 2, 'ingot': 1}],
   {'ingot': 1, 'shard': 2, 'thread': 1}),
  ('regression over-repair clamp #2',
   [{'rarity': 'epic', 'durability': 25, 'max_durability': 20}, {'shard': 5, 'cloth': 3}],
   {'cloth': 2, 'shard': 4}),
  ('regression over-repair clamp #3',
   [{'rarity': 'rare', 'durability': 25, 'max_durability': 20}, {'ingot': 6, 'cloth': 3}],
   {'cloth': 2, 'ingot': 4}),
  ('regression over-repair clamp #4',
   [{'rarity': 'common', 'durability': 12, 'max_durability': 7}, {'shard': 6, 'cloth': 6}],
   {'cloth': 3, 'shard': 3}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 0}, {'cloth': 5, 'ingot': 4, 'shard': 1}],
   {'cloth': 3, 'ingot': 2, 'shard': 1})]]
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(item, components):
    pct = {'common': 50, 'rare': 70, 'epic': 90}[item['rarity']]
    mx = item['max_durability']
    if mx == 0:
        d, mx = 1, 1
    else:
        d = min(item['durability'], 100)
    if d <= 0:
        return {'scrap': 1}
    out = {}
    for name, count in components.items():
        amt = count * pct * d // (100 * mx)
        if item['rarity'] != 'common' and amt < 1:
            amt = 1
        if amt:
            out[name] = amt
    return dict(sorted(out.items()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('regression over-repair clamp #1',
   [{'rarity': 'epic', 'durability': 12, 'max_durability': 7}, {'ingot': 5}],
   {'ingot': 4}),
  ('regression over-repair clamp #2',
   [{'rarity': 'rare', 'durability': 12, 'max_durability': 7}, {'cloth': 3}],
   {'cloth': 2}),
  ('regression over-repair clamp #3',
   [{'rarity': 'epic', 'durability': 12, 'max_durability': 7}, {'thread': 4, 'ingot': 5}],
   {'ingot': 4, 'thread': 3}),
  ('regression over-repair clamp #4',
   [{'rarity': 'rare', 'durability': 15, 'max_durability': 10}, {'thread': 2, 'ingot': 3, 'shard': 2}],
   {'ingot': 2, 'shard': 1, 'thread': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {})],
 [('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('regression over-repair clamp #1',
   [{'rarity': 'rare', 'durability': 12, 'max_durability': 7}, {'cloth': 3}],
   {'cloth': 2}),
  ('regression over-repair clamp #2',
   [{'rarity': 'epic', 'durability': 12, 'max_durability': 7}, {'thread': 4, 'ingot': 5}],
   {'ingot': 4, 'thread': 3}),
  ('regression over-repair clamp #3',
   [{'rarity': 'rare', 'durability': 15, 'max_durability': 10}, {'thread': 2, 'ingot': 3, 'shard': 2}],
   {'ingot': 2, 'shard': 1, 'thread': 1}),
  ('regression over-repair clamp #4',
   [{'rarity': 'epic', 'durability': 25, 'max_durability': 20}, {'ingot': 6}],
   {'ingot': 5}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {})],
 [('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('regression over-repair clamp #1',
   [{'rarity': 'rare', 'durability': 15, 'max_durability': 10}, {'thread': 2, 'ingot': 3, 'shard': 2}],
   {'ingot': 2, 'shard': 1, 'thread': 1}),
  ('regression over-repair clamp #2',
   [{'rarity': 'epic', 'durability': 25, 'max_durability': 20}, {'ingot': 6}],
   {'ingot': 5}),
  ('regression over-repair clamp #3',
   [{'rarity': 'rare', 'durability': 25, 'max_durability': 20}, {'ingot': 5, 'thread': 2, 'shard': 1}],
   {'ingot': 3, 'shard': 1, 'thread': 1}),
  ('regression over-repair clamp #4',
   [{'rarity': 'epic', 'durability': 15, 'max_durability': 10}, {'shard': 6}],
   {'shard': 5}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {})],
 [('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('regression over-repair clamp #1',
   [{'rarity': 'rare', 'durability': 25, 'max_durability': 20}, {'ingot': 5, 'thread': 2, 'shard': 1}],
   {'ingot': 3, 'shard': 1, 'thread': 1}),
  ('regression over-repair clamp #2',
   [{'rarity': 'epic', 'durability': 15, 'max_durability': 10}, {'shard': 6}],
   {'shard': 5}),
  ('regression over-repair clamp #3',
   [{'rarity': 'rare', 'durability': 25, 'max_durability': 20}, {'shard': 4, 'thread': 2, 'ingot': 1}],
   {'ingot': 1, 'shard': 2, 'thread': 1}),
  ('regression over-repair clamp #4',
   [{'rarity': 'epic', 'durability': 25, 'max_durability': 20}, {'shard': 5, 'cloth': 3}],
   {'cloth': 2, 'shard': 4}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1', [{'rarity': 'rare', 'durability': 0, 'max_durability': 100}, {'shard': 5}], {'scrap': 1})],
 [('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('regression over-repair clamp #1',
   [{'rarity': 'rare', 'durability': 25, 'max_durability': 20}, {'shard': 4, 'thread': 2, 'ingot': 1}],
   {'ingot': 1, 'shard': 2, 'thread': 1}),
  ('regression over-repair clamp #2',
   [{'rarity': 'epic', 'durability': 25, 'max_durability': 20}, {'shard': 5, 'cloth': 3}],
   {'cloth': 2, 'shard': 4}),
  ('regression over-repair clamp #3',
   [{'rarity': 'rare', 'durability': 25, 'max_durability': 20}, {'ingot': 6, 'cloth': 3}],
   {'cloth': 2, 'ingot': 4}),
  ('regression over-repair clamp #4',
   [{'rarity': 'common', 'durability': 12, 'max_durability': 7}, {'shard': 6, 'cloth': 6}],
   {'cloth': 3, 'shard': 3}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 0}, {'cloth': 5, 'ingot': 4, 'shard': 1}],
   {'cloth': 3, 'ingot': 2, 'shard': 1})]]
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:
Items repaired past maximum durability return more than 100% condition.

Return rate: common 50%, rare 70%, epic 90%. Condition d/mx with d clamped to mx; max_durability 0 means indestructible (full condition). Durability <= 0 yields {"scrap": 1}. Each component amount = floor(count*pct*d/(100*mx)) computed once; rare and epic items return at least 1 of each component; zero amounts are omitted.

split: open-access


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

N = 1
observations = []
def solve(item, components):
    pct = {'common': 50, 'rare': 70, 'epic': 90}[item['rarity']]
    mx = item['max_durability']
    if mx == 0:
        d, mx = 1, 1
    else:
        d = min(item['durability'], mx)
    if d < 0:
        return {'scrap': 1}
    out = {}
    for name, count in components.items():
        amt = count * pct * d // (100 * mx)
        if item['rarity'] != 'common' and amt < 1:
            amt = 1
        if amt:
            out[name] = amt
    return dict(sorted(out.items()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('regression broken item gate #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 100}, {'shard': 5}],
   {'scrap': 1}),
  ('fault site broken item gate #1',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 100}, {'cloth': 6, 'thread': 1}],
   {'scrap': 1}),
  ('regression broken item gate #2',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 10}, {'cloth': 6}],
   {'scrap': 1}),
  ('regression broken item gate #3',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 10}, {'ingot': 5, 'thread': 3}],
   {'scrap': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('control #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {})],
 [('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('fault site broken item gate #1',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 100}, {'cloth': 6, 'thread': 1}],
   {'scrap': 1}),
  ('fault site broken item gate #2',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 10}, {'thread': 3}],
   {'scrap': 1}),
  ('regression broken item gate #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 10}, {'cloth': 6}],
   {'scrap': 1}),
  ('regression broken item gate #2',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 10}, {'ingot': 5, 'thread': 3}],
   {'scrap': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('control #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {})],
 [('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('regression broken item gate #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 10}, {'cloth': 6}],
   {'scrap': 1}),
  ('regression broken item gate #2',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 10}, {'ingot': 5, 'thread': 3}],
   {'scrap': 1}),
  ('regression broken item gate #3',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 7}, {'cloth': 5, 'shard': 5, 'ingot': 1}],
   {'scrap': 1}),
  ('regression broken item gate #4',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 20}, {'cloth': 6, 'thread': 2, 'shard': 3}],
   {'scrap': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('control #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {})],
 [('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('fault site broken item gate #1',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 7}, {'thread': 4, 'cloth': 5}],
   {'scrap': 1}),
  ('regression broken item gate #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 7}, {'cloth': 5, 'shard': 5, 'ingot': 1}],
   {'scrap': 1}),
  ('regression broken item gate #2',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 100}, {'shard': 2, 'ingot': 4, 'thread': 1}],
   {'scrap': 1}),
  ('regression broken item gate #3',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 100}, {'ingot': 2, 'shard': 5, 'cloth': 5}],
   {'scrap': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('control #1',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 0}, {'cloth': 5, 'ingot': 4, 'shard': 1}],
   {'cloth': 3, 'ingot': 2, 'shard': 1})],
 [('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('fault site broken item gate #1',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 7}, {'cloth': 6, 'ingot': 4, 'shard': 2}],
   {'scrap': 1}),
  ('regression broken item gate #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 20}, {'cloth': 6, 'thread': 2, 'shard': 3}],
   {'scrap': 1}),
  ('regression broken item gate #2',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 7}, {'shard': 1, 'thread': 2, 'ingot': 2}],
   {'scrap': 1}),
  ('regression broken item gate #3',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 7}, {'ingot': 6}],
   {'scrap': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('control #1',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 0}, {'shard': 2, 'ingot': 2, 'thread': 6}],
   {'ingot': 1, 'shard': 1, 'thread': 3})]]
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(item, components):
    pct = {'common': 50, 'rare': 70, 'epic': 90}[item['rarity']]
    mx = item['max_durability']
    if mx == 0:
        d, mx = 1, 1
    else:
        d = min(item['durability'], mx)
    if d <= 0 and item['rarity'] == 'common':
        return {'scrap': 1}
    out = {}
    for name, count in components.items():
        amt = count * pct * d // (100 * mx)
        if item['rarity'] != 'common' and amt < 1:
            amt = 1
        if amt:
            out[name] = amt
    return dict(sorted(out.items()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('regression broken item gate #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 100}, {'shard': 5}],
   {'scrap': 1}),
  ('fault site broken item gate #1',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 100}, {'cloth': 6, 'thread': 1}],
   {'scrap': 1}),
  ('regression broken item gate #2',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 10}, {'cloth': 6}],
   {'scrap': 1}),
  ('regression broken item gate #3',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 10}, {'ingot': 5, 'thread': 3}],
   {'scrap': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('control #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {})],
 [('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('fault site broken item gate #1',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 100}, {'cloth': 6, 'thread': 1}],
   {'scrap': 1}),
  ('fault site broken item gate #2',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 10}, {'thread': 3}],
   {'scrap': 1}),
  ('regression broken item gate #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 10}, {'cloth': 6}],
   {'scrap': 1}),
  ('regression broken item gate #2',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 10}, {'ingot': 5, 'thread': 3}],
   {'scrap': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('control #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {})],
 [('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('regression broken item gate #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 10}, {'cloth': 6}],
   {'scrap': 1}),
  ('regression broken item gate #2',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 10}, {'ingot': 5, 'thread': 3}],
   {'scrap': 1}),
  ('regression broken item gate #3',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 7}, {'cloth': 5, 'shard': 5, 'ingot': 1}],
   {'scrap': 1}),
  ('regression broken item gate #4',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 20}, {'cloth': 6, 'thread': 2, 'shard': 3}],
   {'scrap': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('control #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {})],
 [('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('fault site broken item gate #1',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 7}, {'thread': 4, 'cloth': 5}],
   {'scrap': 1}),
  ('regression broken item gate #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 7}, {'cloth': 5, 'shard': 5, 'ingot': 1}],
   {'scrap': 1}),
  ('regression broken item gate #2',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 100}, {'shard': 2, 'ingot': 4, 'thread': 1}],
   {'scrap': 1}),
  ('regression broken item gate #3',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 100}, {'ingot': 2, 'shard': 5, 'cloth': 5}],
   {'scrap': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('control #1',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 0}, {'cloth': 5, 'ingot': 4, 'shard': 1}],
   {'cloth': 3, 'ingot': 2, 'shard': 1})],
 [('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('fault site broken item gate #1',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 7}, {'cloth': 6, 'ingot': 4, 'shard': 2}],
   {'scrap': 1}),
  ('regression broken item gate #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 20}, {'cloth': 6, 'thread': 2, 'shard': 3}],
   {'scrap': 1}),
  ('regression broken item gate #2',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 7}, {'shard': 1, 'thread': 2, 'ingot': 2}],
   {'scrap': 1}),
  ('regression broken item gate #3',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 7}, {'ingot': 6}],
   {'scrap': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('control #1',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 0}, {'shard': 2, 'ingot': 2, 'thread': 6}],
   {'ingot': 1, 'shard': 1, 'thread': 3})]]
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:
A zero-durability rare item returns guaranteed components instead of scrap.

Return rate: common 50%, rare 70%, epic 90%. Condition d/mx with d clamped to mx; max_durability 0 means indestructible (full condition). Durability <= 0 yields {"scrap": 1}. Each component amount = floor(count*pct*d/(100*mx)) computed once; rare and epic items return at least 1 of each component; zero amounts are omitted.

split: open-access


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

N = 1
observations = []
def solve(item, components):
    pct = {'common': 50, 'rare': 70, 'epic': 90}[item['rarity']]
    mx = item['max_durability']
    if mx == 0:
        d, mx = 1, 1
    else:
        d = min(item['durability'], mx)
    if d <= 0:
        return {'scrap': 1}
    out = {}
    for name, count in components.items():
        amt = count * pct * d // (100 * mx)
        if item['rarity'] == 'epic' and amt < 1:
            amt = 1
        if amt:
            out[name] = amt
    return dict(sorted(out.items()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression rarity guarantee scope #1',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 0}, {'cloth': 5, 'ingot': 4, 'shard': 1}],
   {'cloth': 3, 'ingot': 2, 'shard': 1}),
  ('fault site rarity guarantee scope #1',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 50}, {'ingot': 4, 'shard': 3}],
   {'ingot': 1, 'shard': 1}),
  ('partial repair boundary #1',
   [{'rarity': 'epic', 'durability': 1, 'max_durability': 50}, {'cloth': 1}],
   {'cloth': 1}),
  ('partial repair boundary #2',
   [{'rarity': 'epic', 'durability': 1, 'max_durability': 100}, {'cloth': 6, 'ingot': 1, 'thread': 3}],
   {'cloth': 1, 'ingot': 1, 'thread': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {})],
 [('fault site rarity guarantee scope #1',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 20}, {'ingot': 3, 'shard': 3, 'thread': 5}],
   {'ingot': 1, 'shard': 1, 'thread': 1}),
  ('fault site rarity guarantee scope #2',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 100}, {'cloth': 4}],
   {'cloth': 1}),
  ('partial repair boundary #1',
   [{'rarity': 'epic', 'durability': 1, 'max_durability': 100}, {'cloth': 6, 'ingot': 1, 'thread': 3}],
   {'cloth': 1, 'ingot': 1, 'thread': 1}),
  ('regression rarity guarantee scope #1',
   [{'rarity': 'rare', 'durability': 7, 'max_durability': 7}, {'ingot': 2, 'cloth': 3, 'thread': 1}],
   {'cloth': 2, 'ingot': 1, 'thread': 1}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('control #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {}),
  ('control #2', [{'rarity': 'rare', 'durability': 0, 'max_durability': 100}, {'shard': 5}], {'scrap': 1})],
 [('fault site rarity guarantee scope #1',
   [{'rarity': 'rare', 'durability': 2, 'max_durability': 7}, {'shard': 2, 'thread': 4, 'cloth': 2}],
   {'cloth': 1, 'shard': 1, 'thread': 1}),
  ('regression rarity guarantee scope #1',
   [{'rarity': 'rare', 'durability': 7, 'max_durability': 7}, {'ingot': 2, 'cloth': 3, 'thread': 1}],
   {'cloth': 2, 'ingot': 1, 'thread': 1}),
  ('partial repair boundary #1',
   [{'rarity': 'epic', 'durability': 7, 'max_durability': 7}, {'thread': 2, 'ingot': 1, 'cloth': 1}],
   {'cloth': 1, 'ingot': 1, 'thread': 1}),
  ('regression rarity guarantee scope #2',
   [{'rarity': 'rare', 'durability': 5, 'max_durability': 20}, {'cloth': 2, 'thread': 1}],
   {'cloth': 1, 'thread': 1}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1', [{'rarity': 'rare', 'durability': 0, 'max_durability': 100}, {'shard': 5}], {'scrap': 1}),
  ('control #2',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 100}, {'cloth': 6, 'thread': 1}],
   {'scrap': 1})],
 [('regression rarity guarantee scope #1',
   [{'rarity': 'rare', 'durability': 5, 'max_durability': 20}, {'cloth': 2, 'thread': 1}],
   {'cloth': 1, 'thread': 1}),
  ('fault site rarity guarantee scope #1',
   [{'rarity': 'rare', 'durability': 5, 'max_durability': 20}, {'cloth': 2, 'ingot': 4}],
   {'cloth': 1, 'ingot': 1}),
  ('partial repair boundary #1',
   [{'rarity': 'epic', 'durability': 31, 'max_durability': 100}, {'thread': 1, 'cloth': 4, 'shard': 6}],
   {'cloth': 1, 'shard': 1, 'thread': 1}),
  ('regression rarity guarantee scope #2',
   [{'rarity': 'rare', 'durability': 25, 'max_durability': 20}, {'ingot': 5, 'thread': 2, 'shard': 1}],
   {'ingot': 3, 'shard': 1, 'thread': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('control #1',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 0}, {'shard': 2, 'ingot': 2, 'thread': 6}],
   {'ingot': 1, 'shard': 1, 'thread': 3}),
  ('control #2',
   [{'rarity': 'common', 'durability': 50, 'max_durability': 50}, {'thread': 1, 'ingot': 1}],
   {})],
 [('fault site rarity guarantee scope #1',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 50}, {'cloth': 6}],
   {'cloth': 1}),
  ('fault site rarity guarantee scope #2',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 7}, {'cloth': 2, 'ingot': 4, 'shard': 6}],
   {'cloth': 1, 'ingot': 1, 'shard': 1}),
  ('partial repair boundary #1',
   [{'rarity': 'epic', 'durability': 1, 'max_durability': 20}, {'ingot': 1, 'thread': 1}],
   {'ingot': 1, 'thread': 1}),
  ('partial repair boundary #2',
   [{'rarity': 'epic', 'durability': 3, 'max_durability': 50}, {'thread': 4, 'shard': 2, 'cloth': 1}],
   {'cloth': 1, 'shard': 1, 'thread': 1}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('control #1', [{'rarity': 'epic', 'durability': 12, 'max_durability': 7}, {'ingot': 5}], {'ingot': 4}),
  ('control #2', [{'rarity': 'common', 'durability': 0, 'max_durability': 10}, {'thread': 3}], {'scrap': 1})]]
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(item, components):
    pct = {'common': 50, 'rare': 70, 'epic': 90}[item['rarity']]
    mx = item['max_durability']
    if mx == 0:
        d, mx = 1, 1
    else:
        d = min(item['durability'], mx)
    if d <= 0:
        return {'scrap': 1}
    out = {}
    for name, count in components.items():
        amt = count * pct * d // (100 * mx)
        if item['rarity'] != 'common' and count > 1 and amt < 1:
            amt = 1
        if amt:
            out[name] = amt
    return dict(sorted(out.items()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression rarity guarantee scope #1',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 0}, {'cloth': 5, 'ingot': 4, 'shard': 1}],
   {'cloth': 3, 'ingot': 2, 'shard': 1}),
  ('fault site rarity guarantee scope #1',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 50}, {'ingot': 4, 'shard': 3}],
   {'ingot': 1, 'shard': 1}),
  ('partial repair boundary #1',
   [{'rarity': 'epic', 'durability': 1, 'max_durability': 50}, {'cloth': 1}],
   {'cloth': 1}),
  ('partial repair boundary #2',
   [{'rarity': 'epic', 'durability': 1, 'max_durability': 100}, {'cloth': 6, 'ingot': 1, 'thread': 3}],
   {'cloth': 1, 'ingot': 1, 'thread': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {})],
 [('fault site rarity guarantee scope #1',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 20}, {'ingot': 3, 'shard': 3, 'thread': 5}],
   {'ingot': 1, 'shard': 1, 'thread': 1}),
  ('fault site rarity guarantee scope #2',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 100}, {'cloth': 4}],
   {'cloth': 1}),
  ('partial repair boundary #1',
   [{'rarity': 'epic', 'durability': 1, 'max_durability': 100}, {'cloth': 6, 'ingot': 1, 'thread': 3}],
   {'cloth': 1, 'ingot': 1, 'thread': 1}),
  ('regression rarity guarantee scope #1',
   [{'rarity': 'rare', 'durability': 7, 'max_durability': 7}, {'ingot': 2, 'cloth': 3, 'thread': 1}],
   {'cloth': 2, 'ingot': 1, 'thread': 1}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('control #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {}),
  ('control #2', [{'rarity': 'rare', 'durability': 0, 'max_durability': 100}, {'shard': 5}], {'scrap': 1})],
 [('fault site rarity guarantee scope #1',
   [{'rarity': 'rare', 'durability': 2, 'max_durability': 7}, {'shard': 2, 'thread': 4, 'cloth': 2}],
   {'cloth': 1, 'shard': 1, 'thread': 1}),
  ('regression rarity guarantee scope #1',
   [{'rarity': 'rare', 'durability': 7, 'max_durability': 7}, {'ingot': 2, 'cloth': 3, 'thread': 1}],
   {'cloth': 2, 'ingot': 1, 'thread': 1}),
  ('partial repair boundary #1',
   [{'rarity': 'epic', 'durability': 7, 'max_durability': 7}, {'thread': 2, 'ingot': 1, 'cloth': 1}],
   {'cloth': 1, 'ingot': 1, 'thread': 1}),
  ('regression rarity guarantee scope #2',
   [{'rarity': 'rare', 'durability': 5, 'max_durability': 20}, {'cloth': 2, 'thread': 1}],
   {'cloth': 1, 'thread': 1}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1', [{'rarity': 'rare', 'durability': 0, 'max_durability': 100}, {'shard': 5}], {'scrap': 1}),
  ('control #2',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 100}, {'cloth': 6, 'thread': 1}],
   {'scrap': 1})],
 [('regression rarity guarantee scope #1',
   [{'rarity': 'rare', 'durability': 5, 'max_durability': 20}, {'cloth': 2, 'thread': 1}],
   {'cloth': 1, 'thread': 1}),
  ('fault site rarity guarantee scope #1',
   [{'rarity': 'rare', 'durability': 5, 'max_durability': 20}, {'cloth': 2, 'ingot': 4}],
   {'cloth': 1, 'ingot': 1}),
  ('partial repair boundary #1',
   [{'rarity': 'epic', 'durability': 31, 'max_durability': 100}, {'thread': 1, 'cloth': 4, 'shard': 6}],
   {'cloth': 1, 'shard': 1, 'thread': 1}),
  ('regression rarity guarantee scope #2',
   [{'rarity': 'rare', 'durability': 25, 'max_durability': 20}, {'ingot': 5, 'thread': 2, 'shard': 1}],
   {'ingot': 3, 'shard': 1, 'thread': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('control #1',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 0}, {'shard': 2, 'ingot': 2, 'thread': 6}],
   {'ingot': 1, 'shard': 1, 'thread': 3}),
  ('control #2',
   [{'rarity': 'common', 'durability': 50, 'max_durability': 50}, {'thread': 1, 'ingot': 1}],
   {})],
 [('fault site rarity guarantee scope #1',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 50}, {'cloth': 6}],
   {'cloth': 1}),
  ('fault site rarity guarantee scope #2',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 7}, {'cloth': 2, 'ingot': 4, 'shard': 6}],
   {'cloth': 1, 'ingot': 1, 'shard': 1}),
  ('partial repair boundary #1',
   [{'rarity': 'epic', 'durability': 1, 'max_durability': 20}, {'ingot': 1, 'thread': 1}],
   {'ingot': 1, 'thread': 1}),
  ('partial repair boundary #2',
   [{'rarity': 'epic', 'durability': 3, 'max_durability': 50}, {'thread': 4, 'shard': 2, 'cloth': 1}],
   {'cloth': 1, 'shard': 1, 'thread': 1}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('control #1', [{'rarity': 'epic', 'durability': 12, 'max_durability': 7}, {'ingot': 5}], {'ingot': 4}),
  ('control #2', [{'rarity': 'common', 'durability': 0, 'max_durability': 10}, {'thread': 3}], {'scrap': 1})]]
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:
Worn rare items can return zero of a component.

Return rate: common 50%, rare 70%, epic 90%. Condition d/mx with d clamped to mx; max_durability 0 means indestructible (full condition). Durability <= 0 yields {"scrap": 1}. Each component amount = floor(count*pct*d/(100*mx)) computed once; rare and epic items return at least 1 of each component; zero amounts are omitted.

split: open-access


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

N = 1
observations = []
def solve(item, components):
    pct = {'common': 50, 'rare': 70, 'epic': 90}[item['rarity']]
    mx = item['max_durability']
    if mx == 0:
        d, mx = 1, 1
    else:
        d = min(item['durability'], mx)
    if d <= 0:
        return {'scrap': 1}
    out = {}
    for name, count in components.items():
        amt = count * pct * d // (100 * mx)
        if item['rarity'] != 'common' and amt < 1:
            amt = 1
        if amt >= 0:
            out[name] = amt
    return dict(sorted(out.items()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('fault site zero amount omission #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {}),
  ('fault site zero amount omission #2',
   [{'rarity': 'common', 'durability': 50, 'max_durability': 50}, {'thread': 1, 'ingot': 1}],
   {}),
  ('partial repair boundary #1',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 0}, {'cloth': 5, 'ingot': 4, 'shard': 1}],
   {'cloth': 3, 'ingot': 2, 'shard': 1}),
  ('partial repair boundary #2',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 0}, {'shard': 2, 'ingot': 2, 'thread': 6}],
   {'ingot': 1, 'shard': 1, 'thread': 3}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1', [{'rarity': 'rare', 'durability': 0, 'max_durability': 100}, {'shard': 5}], {'scrap': 1})],
 [('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('fault site zero amount omission #1',
   [{'rarity': 'common', 'durability': 7, 'max_durability': 7}, {'thread': 1}],
   {}),
  ('fault site zero amount omission #2',
   [{'rarity': 'common', 'durability': 4, 'max_durability': 20}, {'thread': 4, 'shard': 3}],
   {}),
  ('partial repair boundary #1',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 0}, {'shard': 2, 'ingot': 2, 'thread': 6}],
   {'ingot': 1, 'shard': 1, 'thread': 3}),
  ('partial repair boundary #2',
   [{'rarity': 'epic', 'durability': 1, 'max_durability': 50}, {'cloth': 1}],
   {'cloth': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1', [{'rarity': 'rare', 'durability': 0, 'max_durability': 100}, {'shard': 5}], {'scrap': 1})],
 [('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('fault site zero amount omission #1',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 50}, {'ingot': 4, 'thread': 6}],
   {}),
  ('fault site zero amount omission #2',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 10}, {'shard': 5, 'thread': 6}],
   {}),
  ('partial repair boundary #1',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 50}, {'ingot': 4, 'shard': 3}],
   {'ingot': 1, 'shard': 1}),
  ('partial repair boundary #2',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 20}, {'ingot': 3, 'shard': 3, 'thread': 5}],
   {'ingot': 1, 'shard': 1, 'thread': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1', [{'rarity': 'rare', 'durability': 0, 'max_durability': 100}, {'shard': 5}], {'scrap': 1})],
 [('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('fault site zero amount omission #1',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 7}, {'shard': 2, 'cloth': 6, 'ingot': 2}],
   {}),
  ('fault site zero amount omission #2',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 7}, {'thread': 2}],
   {}),
  ('partial repair boundary #1',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 100}, {'cloth': 4}],
   {'cloth': 1}),
  ('partial repair boundary #2',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 0}, {'cloth': 6, 'ingot': 2}],
   {'cloth': 3, 'ingot': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 100}, {'cloth': 6, 'thread': 1}],
   {'scrap': 1})],
 [('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('fault site zero amount omission #1',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 7}, {'shard': 2, 'ingot': 6, 'thread': 4}],
   {}),
  ('fault site zero amount omission #2',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 7}, {'cloth': 3}],
   {}),
  ('partial repair boundary #1',
   [{'rarity': 'epic', 'durability': 1, 'max_durability': 100}, {'cloth': 6, 'ingot': 1, 'thread': 3}],
   {'cloth': 1, 'ingot': 1, 'thread': 1}),
  ('partial repair boundary #2',
   [{'rarity': 'common', 'durability': 20, 'max_durability': 20}, {'shard': 4, 'thread': 2}],
   {'shard': 2, 'thread': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1', [{'rarity': 'epic', 'durability': 12, 'max_durability': 7}, {'ingot': 5}], {'ingot': 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(item, components):
    pct = {'common': 50, 'rare': 70, 'epic': 90}[item['rarity']]
    mx = item['max_durability']
    if mx == 0:
        d, mx = 1, 1
    else:
        d = min(item['durability'], mx)
    if d <= 0:
        return {'scrap': 1}
    out = {}
    for name, count in components.items():
        amt = count * pct * d // (100 * mx)
        if item['rarity'] != 'common' and amt < 1:
            amt = 1
        if amt > 1:
            out[name] = amt
    return dict(sorted(out.items()))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('fault site zero amount omission #1',
   [{'rarity': 'common', 'durability': 3, 'max_durability': 10}, {'thread': 4, 'cloth': 5}],
   {}),
  ('fault site zero amount omission #2',
   [{'rarity': 'common', 'durability': 50, 'max_durability': 50}, {'thread': 1, 'ingot': 1}],
   {}),
  ('partial repair boundary #1',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 0}, {'cloth': 5, 'ingot': 4, 'shard': 1}],
   {'cloth': 3, 'ingot': 2, 'shard': 1}),
  ('partial repair boundary #2',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 0}, {'shard': 2, 'ingot': 2, 'thread': 6}],
   {'ingot': 1, 'shard': 1, 'thread': 3}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1', [{'rarity': 'rare', 'durability': 0, 'max_durability': 100}, {'shard': 5}], {'scrap': 1})],
 [('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('fault site zero amount omission #1',
   [{'rarity': 'common', 'durability': 7, 'max_durability': 7}, {'thread': 1}],
   {}),
  ('fault site zero amount omission #2',
   [{'rarity': 'common', 'durability': 4, 'max_durability': 20}, {'thread': 4, 'shard': 3}],
   {}),
  ('partial repair boundary #1',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 0}, {'shard': 2, 'ingot': 2, 'thread': 6}],
   {'ingot': 1, 'shard': 1, 'thread': 3}),
  ('partial repair boundary #2',
   [{'rarity': 'epic', 'durability': 1, 'max_durability': 50}, {'cloth': 1}],
   {'cloth': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1', [{'rarity': 'rare', 'durability': 0, 'max_durability': 100}, {'shard': 5}], {'scrap': 1})],
 [('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('fault site zero amount omission #1',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 50}, {'ingot': 4, 'thread': 6}],
   {}),
  ('fault site zero amount omission #2',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 10}, {'shard': 5, 'thread': 6}],
   {}),
  ('partial repair boundary #1',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 50}, {'ingot': 4, 'shard': 3}],
   {'ingot': 1, 'shard': 1}),
  ('partial repair boundary #2',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 20}, {'ingot': 3, 'shard': 3, 'thread': 5}],
   {'ingot': 1, 'shard': 1, 'thread': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1', [{'rarity': 'rare', 'durability': 0, 'max_durability': 100}, {'shard': 5}], {'scrap': 1})],
 [('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('fault site zero amount omission #1',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 7}, {'shard': 2, 'cloth': 6, 'ingot': 2}],
   {}),
  ('fault site zero amount omission #2',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 7}, {'thread': 2}],
   {}),
  ('partial repair boundary #1',
   [{'rarity': 'rare', 'durability': 1, 'max_durability': 100}, {'cloth': 4}],
   {'cloth': 1}),
  ('partial repair boundary #2',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 0}, {'cloth': 6, 'ingot': 2}],
   {'cloth': 3, 'ingot': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1',
   [{'rarity': 'common', 'durability': 0, 'max_durability': 100}, {'cloth': 6, 'thread': 1}],
   {'scrap': 1})],
 [('over-repaired common #1',
   [{'rarity': 'common', 'durability': 30, 'max_durability': 20}, {'ingot': 4, 'cloth': 3}],
   {'cloth': 1, 'ingot': 2}),
  ('fault site zero amount omission #1',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 7}, {'shard': 2, 'ingot': 6, 'thread': 4}],
   {}),
  ('fault site zero amount omission #2',
   [{'rarity': 'common', 'durability': 1, 'max_durability': 7}, {'cloth': 3}],
   {}),
  ('partial repair boundary #1',
   [{'rarity': 'epic', 'durability': 1, 'max_durability': 100}, {'cloth': 6, 'ingot': 1, 'thread': 3}],
   {'cloth': 1, 'ingot': 1, 'thread': 1}),
  ('partial repair boundary #2',
   [{'rarity': 'common', 'durability': 20, 'max_durability': 20}, {'shard': 4, 'thread': 2}],
   {'shard': 2, 'thread': 1}),
  ('indestructible relic #1',
   [{'rarity': 'epic', 'durability': 0, 'max_durability': 0}, {'shard': 5}],
   {'shard': 4}),
  ('broken rare #1',
   [{'rarity': 'rare', 'durability': 0, 'max_durability': 40}, {'thread': 2}],
   {'scrap': 1}),
  ('control #1', [{'rarity': 'epic', 'durability': 12, 'max_durability': 7}, {'ingot': 5}], {'ingot': 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:
Salvage results contain components with amount zero.

Return rate: common 50%, rare 70%, epic 90%. Condition d/mx with d clamped to mx; max_durability 0 means indestructible (full condition). Durability <= 0 yields {"scrap": 1}. Each component amount = floor(count*pct*d/(100*mx)) computed once; rare and epic items return at least 1 of each component; zero amounts are omitted.

split: open-access


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

N = 1
observations = []
def solve(rolls, state):
    pity = state['pity']
    guarantee = state['guarantee']
    out = []
    for r in rolls:
        n = pity
        rate = 6
        if n >= 74:
            rate += 50 * (n - 73)
        if n >= 90 or r < rate:
            pity = 0
            if guarantee or r % 2 == 0:
                out.append('F')
                guarantee = False
            else:
                out.append('L')
                guarantee = True
        else:
            pity = n
            out.append('-')
    return {'results': ''.join(out), 'pity': pity, 'guarantee': guarantee}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression pull numbering #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False}),
  ('regression pull numbering #2',
   [[507, 965, 27, 525, 851], {'pity': 73, 'guarantee': True}],
   {'results': '--F--', 'pity': 2, 'guarantee': False}),
  ('regression pull numbering #3',
   [[480, 489, 823, 13, 936, 776, 44, 409, 26, 974, 9, 54, 911, 804, 433, 47, 942, 847],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F-----------------', 'pity': 17, 'guarantee': False}),
  ('regression pull numbering #4',
   [[922, 571, 11, 40, 49, 776, 996, 952, 946, 14, 108, 822, 888, 25], {'pity': 84, 'guarantee': False}],
   {'results': '-L------------', 'pity': 12, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[18, 973, 5], {'pity': 72, 'guarantee': False}],
   {'results': '--L', 'pity': 0, 'guarantee': True})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression pull numbering #1',
   [[507, 965, 27, 525, 851], {'pity': 73, 'guarantee': True}],
   {'results': '--F--', 'pity': 2, 'guarantee': False}),
  ('regression pull numbering #2',
   [[480, 489, 823, 13, 936, 776, 44, 409, 26, 974, 9, 54, 911, 804, 433, 47, 942, 847],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F-----------------', 'pity': 17, 'guarantee': False}),
  ('regression pull numbering #3',
   [[922, 571, 11, 40, 49, 776, 996, 952, 946, 14, 108, 822, 888, 25], {'pity': 84, 'guarantee': False}],
   {'results': '-L------------', 'pity': 12, 'guarantee': True}),
  ('regression pull numbering #4',
   [[911], {'pity': 73, 'guarantee': True}],
   {'results': '-', 'pity': 74, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[18, 973, 5], {'pity': 72, 'guarantee': False}],
   {'results': '--L', 'pity': 0, 'guarantee': True})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression pull numbering #1',
   [[922, 571, 11, 40, 49, 776, 996, 952, 946, 14, 108, 822, 888, 25], {'pity': 84, 'guarantee': False}],
   {'results': '-L------------', 'pity': 12, 'guarantee': True}),
  ('regression pull numbering #2',
   [[911], {'pity': 73, 'guarantee': True}],
   {'results': '-', 'pity': 74, 'guarantee': True}),
  ('regression pull numbering #3',
   [[935, 90, 29, 166, 937, 997, 903, 315, 848, 1, 893, 36, 218, 730, 858, 726, 972, 10],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F--------L--------', 'pity': 8, 'guarantee': True}),
  ('regression pull numbering #4',
   [[815, 889, 39, 873, 939, 933, 908, 992, 421, 939, 821, 53, 12, 40, 8, 884, 975, 551, 967, 39],
    {'pity': 63, 'guarantee': True}],
   {'results': '-----------F--------', 'pity': 8, 'guarantee': False}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[18, 973, 5], {'pity': 72, 'guarantee': False}],
   {'results': '--L', 'pity': 0, 'guarantee': True})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression pull numbering #1',
   [[935, 90, 29, 166, 937, 997, 903, 315, 848, 1, 893, 36, 218, 730, 858, 726, 972, 10],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F--------L--------', 'pity': 8, 'guarantee': True}),
  ('regression pull numbering #2',
   [[815, 889, 39, 873, 939, 933, 908, 992, 421, 939, 821, 53, 12, 40, 8, 884, 975, 551, 967, 39],
    {'pity': 63, 'guarantee': True}],
   {'results': '-----------F--------', 'pity': 8, 'guarantee': False}),
  ('regression pull numbering #3',
   [[4, 155, 441, 951, 967, 353, 21], {'pity': 68, 'guarantee': False}],
   {'results': 'F------', 'pity': 6, 'guarantee': False}),
  ('regression pull numbering #4',
   [[685, 976, 49, 33, 16, 30, 427, 839], {'pity': 0, 'guarantee': False}],
   {'results': '--------', 'pity': 8, 'guarantee': False}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[857, 5], {'pity': 24, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression pull numbering #1',
   [[4, 155, 441, 951, 967, 353, 21], {'pity': 68, 'guarantee': False}],
   {'results': 'F------', 'pity': 6, 'guarantee': False}),
  ('regression pull numbering #2',
   [[685, 976, 49, 33, 16, 30, 427, 839], {'pity': 0, 'guarantee': False}],
   {'results': '--------', 'pity': 8, 'guarantee': False}),
  ('regression pull numbering #3',
   [[18, 16, 60, 53, 197, 713, 972, 933], {'pity': 75, 'guarantee': True}],
   {'results': 'F-------', 'pity': 7, 'guarantee': False}),
  ('regression pull numbering #4',
   [[773, 957, 60, 353, 59, 19, 862, 820, 993, 27, 22, 893, 950], {'pity': 0, 'guarantee': True}],
   {'results': '-------------', 'pity': 13, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1', [[4], {'pity': 73, 'guarantee': False}], {'results': 'F', 'pity': 0, 'guarantee': False})]]
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(rolls, state):
    pity = state['pity']
    guarantee = state['guarantee']
    out = []
    for r in rolls:
        n = max(pity, 1)
        rate = 6
        if n >= 74:
            rate += 50 * (n - 73)
        if n >= 90 or r < rate:
            pity = 0
            if guarantee or r % 2 == 0:
                out.append('F')
                guarantee = False
            else:
                out.append('L')
                guarantee = True
        else:
            pity = n
            out.append('-')
    return {'results': ''.join(out), 'pity': pity, 'guarantee': guarantee}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression pull numbering #1',
   [[15, 31, 302, 259, 332, 886, 12, 851, 55, 45, 6, 903, 946, 869, 725], {'pity': 88, 'guarantee': True}],
   {'results': 'F--------------', 'pity': 14, 'guarantee': False}),
  ('regression pull numbering #2',
   [[507, 965, 27, 525, 851], {'pity': 73, 'guarantee': True}],
   {'results': '--F--', 'pity': 2, 'guarantee': False}),
  ('regression pull numbering #3',
   [[480, 489, 823, 13, 936, 776, 44, 409, 26, 974, 9, 54, 911, 804, 433, 47, 942, 847],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F-----------------', 'pity': 17, 'guarantee': False}),
  ('regression pull numbering #4',
   [[922, 571, 11, 40, 49, 776, 996, 952, 946, 14, 108, 822, 888, 25], {'pity': 84, 'guarantee': False}],
   {'results': '-L------------', 'pity': 12, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[18, 973, 5], {'pity': 72, 'guarantee': False}],
   {'results': '--L', 'pity': 0, 'guarantee': True})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression pull numbering #1',
   [[507, 965, 27, 525, 851], {'pity': 73, 'guarantee': True}],
   {'results': '--F--', 'pity': 2, 'guarantee': False}),
  ('regression pull numbering #2',
   [[480, 489, 823, 13, 936, 776, 44, 409, 26, 974, 9, 54, 911, 804, 433, 47, 942, 847],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F-----------------', 'pity': 17, 'guarantee': False}),
  ('regression pull numbering #3',
   [[922, 571, 11, 40, 49, 776, 996, 952, 946, 14, 108, 822, 888, 25], {'pity': 84, 'guarantee': False}],
   {'results': '-L------------', 'pity': 12, 'guarantee': True}),
  ('regression pull numbering #4',
   [[911], {'pity': 73, 'guarantee': True}],
   {'results': '-', 'pity': 74, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[18, 973, 5], {'pity': 72, 'guarantee': False}],
   {'results': '--L', 'pity': 0, 'guarantee': True})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression pull numbering #1',
   [[922, 571, 11, 40, 49, 776, 996, 952, 946, 14, 108, 822, 888, 25], {'pity': 84, 'guarantee': False}],
   {'results': '-L------------', 'pity': 12, 'guarantee': True}),
  ('regression pull numbering #2',
   [[911], {'pity': 73, 'guarantee': True}],
   {'results': '-', 'pity': 74, 'guarantee': True}),
  ('regression pull numbering #3',
   [[935, 90, 29, 166, 937, 997, 903, 315, 848, 1, 893, 36, 218, 730, 858, 726, 972, 10],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F--------L--------', 'pity': 8, 'guarantee': True}),
  ('regression pull numbering #4',
   [[815, 889, 39, 873, 939, 933, 908, 992, 421, 939, 821, 53, 12, 40, 8, 884, 975, 551, 967, 39],
    {'pity': 63, 'guarantee': True}],
   {'results': '-----------F--------', 'pity': 8, 'guarantee': False}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[18, 973, 5], {'pity': 72, 'guarantee': False}],
   {'results': '--L', 'pity': 0, 'guarantee': True})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression pull numbering #1',
   [[935, 90, 29, 166, 937, 997, 903, 315, 848, 1, 893, 36, 218, 730, 858, 726, 972, 10],
    {'pity': 89, 'guarantee': True}],
   {'results': 'F--------L--------', 'pity': 8, 'guarantee': True}),
  ('regression pull numbering #2',
   [[815, 889, 39, 873, 939, 933, 908, 992, 421, 939, 821, 53, 12, 40, 8, 884, 975, 551, 967, 39],
    {'pity': 63, 'guarantee': True}],
   {'results': '-----------F--------', 'pity': 8, 'guarantee': False}),
  ('regression pull numbering #3',
   [[4, 155, 441, 951, 967, 353, 21], {'pity': 68, 'guarantee': False}],
   {'results': 'F------', 'pity': 6, 'guarantee': False}),
  ('regression pull numbering #4',
   [[685, 976, 49, 33, 16, 30, 427, 839], {'pity': 0, 'guarantee': False}],
   {'results': '--------', 'pity': 8, 'guarantee': False}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1',
   [[857, 5], {'pity': 24, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False})],
 [('hard pity pull #1',
   [[999, 999], {'pity': 89, 'guarantee': False}],
   {'results': 'L-', 'pity': 1, 'guarantee': True}),
  ('regression pull numbering #1',
   [[4, 155, 441, 951, 967, 353, 21], {'pity': 68, 'guarantee': False}],
   {'results': 'F------', 'pity': 6, 'guarantee': False}),
  ('regression pull numbering #2',
   [[685, 976, 49, 33, 16, 30, 427, 839], {'pity': 0, 'guarantee': False}],
   {'results': '--------', 'pity': 8, 'guarantee': False}),
  ('regression pull numbering #3',
   [[18, 16, 60, 53, 197, 713, 972, 933], {'pity': 75, 'guarantee': True}],
   {'results': 'F-------', 'pity': 7, 'guarantee': False}),
  ('regression pull numbering #4',
   [[773, 957, 60, 353, 59, 19, 862, 820, 993, 27, 22, 893, 950], {'pity': 0, 'guarantee': True}],
   {'results': '-------------', 'pity': 13, 'guarantee': True}),
  ('first soft pity pull #1',
   [[100, 3], {'pity': 73, 'guarantee': True}],
   {'results': '-F', 'pity': 0, 'guarantee': False}),
  ('lost fifty fifty then featured #1',
   [[1, 999, 0], {'pity': 10, 'guarantee': False}],
   {'results': 'L-F', 'pity': 0, 'guarantee': False}),
  ('control #1', [[4], {'pity': 73, 'guarantee': False}], {'results': 'F', 'pity': 0, 'guarantee': False})]]
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:
Players need one more pull than advertised to enter soft and hard pity.

Each roll is 0..999. Pull number n = pity+1. Top-rarity rate is 6 per mille, plus 50*(n-73) from n >= 74 (soft pity); n >= 90 always hits. On a hit pity resets to 0; the item is featured ("F") if guarantee is set or the roll is even, otherwise lost ("L") and the guarantee is set; a featured hit clears the guarantee. Misses ("-") set pity = n.

split: open-access