{"abstract":"Partial stacks overflow past max_stack.","category":"Game economy crafting balance","checks":8,"contract":"slots = list of None or [name, count]; names are case sensitive. First top up partial stacks (count < max_stack) of the same item in slot order, then fill empty slots in order with new stacks of at most max_stack. Reserved placeholders [name, 0] count as partial stacks. Legacy stacks above max_stack are left untouched. Returns {slots, leftover}.","evaluation_group":"w2-game-economy-crafting-balance-inventory-stacking","failed_approach":"Filling to max regardless of the remaining quantity creates items.","family":"w2-game-economy-crafting-balance-inventory-stacking-top-up-amount","id":"FA-86171","implementations":{"attempt":{"sha256":"c320952eb28d0d8c8c5276b30e83876336e04ddb922662d66d186ed7f07fca8a","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(slots, item, qty, max_stack):\n    slots = [s if s is None else list(s) for s in slots]\n    left = qty\n    for s in slots:\n        if left == 0:\n            break\n        if s is not None and s[0] == item and s[1] < max_stack:\n            add = max_stack - s[1]\n            s[1] += add\n            left -= add\n    for i in range(len(slots)):\n        if left == 0:\n            break\n        if slots[i] is None:\n            add = min(left, max_stack)\n            slots[i] = [item, add]\n            left -= add\n    return {'slots': slots, 'leftover': left}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('two partial stacks #1',\n   [[['Arrow', 18], ['Arrow', 15], None], 'Arrow', 4, 20],\n   {'slots': [['Arrow', 20], ['Arrow', 17], None], 'leftover': 0}),\n  ('fault site top-up amount #1',\n   [[None, ['Arrow', 1], ['arrow', 1], ['Potion', 20], ['arrow', 19]], 'arrow', 20, 20],\n   {'slots': [None, ['Arrow', 1], ['arrow', 20], ['Potion', 20], ['arrow', 20]], 'leftover': 0}),\n  ('fault site top-up amount #2',\n   [[None, ['arrow', 5], None, None], 'arrow', 45, 10],\n   {'slots': [['arrow', 10], ['arrow', 10], ['arrow', 10], ['arrow', 10]], 'leftover': 10}),\n  ('partial repair boundary #1',\n   [[None, ['Potion', 0], ['Potion', 20], ['arrow', 1]], 'arrow', 1, 10],\n   {'slots': [None, ['Potion', 0], ['Potion', 20], ['arrow', 2]], 'leftover': 0}),\n  ('partial repair boundary #2',\n   [[['arrow', 5], ['Arrow', 1]], 'Arrow', 1, 20],\n   {'slots': [['arrow', 5], ['Arrow', 2]], 'leftover': 0}),\n  ('legacy overfull stack #1',\n   [[['Arrow', 25], None], 'Arrow', 3, 20],\n   {'slots': [['Arrow', 25], ['Arrow', 3]], 'leftover': 0}),\n  ('case distinct item #1', [[['arrow', 3]], 'Arrow', 2, 20], {'slots': [['arrow', 3]], 'leftover': 2}),\n  ('control #1',\n   [[['Arrow', 6], None, ['arrow', 5]], 'Potion', 0, 20],\n   {'slots': [['Arrow', 6], None, ['arrow', 5]], 'leftover': 0})],\n [('two partial stacks #1',\n   [[['Arrow', 18], ['Arrow', 15], None], 'Arrow', 4, 20],\n   {'slots': [['Arrow', 20], ['Arrow', 17], None], 'leftover': 0}),\n  ('fault site top-up amount #1',\n   [[None, ['arrow', 5], None, None], 'arrow', 45, 10],\n   {'slots': [['arrow', 10], ['arrow', 10], ['arrow', 10], ['arrow', 10]], 'leftover': 10}),\n  ('fault site top-up amount #2',\n   [[None, ['arrow', 1], ['Arrow', 19], ['arrow', 10], None], 'arrow', 20, 5],\n   {'slots': [['arrow', 5], ['arrow', 5], ['Arrow', 19], ['arrow', 10], ['arrow', 5]], 'leftover': 6}),\n  ('partial repair boundary #1',\n   [[['arrow', 5], ['Arrow', 1]], 'Arrow', 1, 20],\n   {'slots': [['arrow', 5], ['Arrow', 2]], 'leftover': 0}),\n  ('partial repair boundary #2',\n   [[['Arrow', 25], ['Arrow', 25], ['Potion', 1]], 'Potion', 7, 20],\n   {'slots': [['Arrow', 25], ['Arrow', 25], ['Potion', 8]], 'leftover': 0}),\n  ('legacy overfull stack #1',\n   [[['Arrow', 25], None], 'Arrow', 3, 20],\n   {'slots': [['Arrow', 25], ['Arrow', 3]], 'leftover': 0}),\n  ('case distinct item #1', [[['arrow', 3]], 'Arrow', 2, 20], {'slots': [['arrow', 3]], 'leftover': 2}),\n  ('control #1',\n   [[['Arrow', 6], None, ['arrow', 5]], 'Potion', 0, 20],\n   {'slots': [['Arrow', 6], None, ['arrow', 5]], 'leftover': 0})],\n [('two partial stacks #1',\n   [[['Arrow', 18], ['Arrow', 15], None], 'Arrow', 4, 20],\n   {'slots': [['Arrow', 20], ['Arrow', 17], None], 'leftover': 0}),\n  ('fault site top-up amount #1',\n   [[['Potion', 17], ['arrow', 1], ['Arrow', 0], ['arrow', 19]], 'arrow', 45, 20],\n   {'slots': [['Potion', 17], ['arrow', 20], ['Arrow', 0], ['arrow', 20]], 'leftover': 25}),\n  ('fault site top-up amount #2',\n   [[['Arrow', 5]], 'Arrow', 20, 20],\n   {'slots': [['Arrow', 20]], 'leftover': 5}),\n  ('partial repair boundary #1',\n   [[['arrow', 1], None, ['Potion', 5]], 'arrow', 7, 20],\n   {'slots': [['arrow', 8], None, ['Potion', 5]], 'leftover': 0}),\n  ('partial repair boundary #2',\n   [[['arrow', 20], ['Arrow', 0], ['Potion', 19]], 'Arrow', 7, 10],\n   {'slots': [['arrow', 20], ['Arrow', 7], ['Potion', 19]], 'leftover': 0}),\n  ('legacy overfull stack #1',\n   [[['Arrow', 25], None], 'Arrow', 3, 20],\n   {'slots': [['Arrow', 25], ['Arrow', 3]], 'leftover': 0}),\n  ('case distinct item #1', [[['arrow', 3]], 'Arrow', 2, 20], {'slots': [['arrow', 3]], 'leftover': 2}),\n  ('control #1',\n   [[['Arrow', 6], None, ['arrow', 5]], 'Potion', 0, 20],\n   {'slots': [['Arrow', 6], None, ['arrow', 5]], 'leftover': 0})],\n [('two partial stacks #1',\n   [[['Arrow', 18], ['Arrow', 15], None], 'Arrow', 4, 20],\n   {'slots': [['Arrow', 20], ['Arrow', 17], None], 'leftover': 0}),\n  ('fault site top-up amount #1',\n   [[['arrow', 25], None, ['Potion', 5], None, ['arrow', 20]], 'Potion', 7, 10],\n   {'slots': [['arrow', 25], ['Potion', 2], ['Potion', 10], None, ['arrow', 20]], 'leftover': 0}),\n  ('fault site top-up amount #2',\n   [[None, None, ['Arrow', 11], ['Potion', 10], ['Arrow', 25], None], 'Potion', 20, 20],\n   {'slots': [['Potion', 10], None, ['Arrow', 11], ['Potion', 20], ['Arrow', 25], None], 'leftover': 0}),\n  ('partial repair boundary #1',\n   [[['arrow', 5], ['Potion', 5], ['Potion', 1], ['Potion', 1], ['Arrow', 3]], 'arrow', 1, 20],\n   {'slots': [['arrow', 6], ['Potion', 5], ['Potion', 1], ['Potion', 1], ['Arrow', 3]], 'leftover': 0}),\n  ('partial repair boundary #2',\n   [[['arrow', 20], ['Arrow', 16], ['arrow', 20], None, None, ['Potion', 0]], 'Potion', 1, 20],\n   {'slots': [['arrow', 20], ['Arrow', 16], ['arrow', 20], None, None, ['Potion', 1]], 'leftover': 0}),\n  ('legacy overfull stack #1',\n   [[['Arrow', 25], None], 'Arrow', 3, 20],\n   {'slots': [['Arrow', 25], ['Arrow', 3]], 'leftover': 0}),\n  ('case distinct item #1', [[['arrow', 3]], 'Arrow', 2, 20], {'slots': [['arrow', 3]], 'leftover': 2}),\n  ('control #1',\n   [[None, ['Arrow', 16], ['arrow', 20], None, ['Arrow', 25], None], 'Potion', 20, 10],\n   {'slots': [['Potion', 10], ['Arrow', 16], ['arrow', 20], ['Potion', 10], ['Arrow', 25], None],\n    'leftover': 0})],\n [('two partial stacks #1',\n   [[['Arrow', 18], ['Arrow', 15], None], 'Arrow', 4, 20],\n   {'slots': [['Arrow', 20], ['Arrow', 17], None], 'leftover': 0}),\n  ('fault site top-up amount #1',\n   [[['Potion', 0], ['Arrow', 0], ['Arrow', 1]], 'Arrow', 45, 10],\n   {'slots': [['Potion', 0], ['Arrow', 10], ['Arrow', 10]], 'leftover': 26}),\n  ('fault site top-up amount #2',\n   [[None, ['Potion', 11], ['arrow', 5], ['Potion', 19], None, ['Arrow', 0]], 'arrow', 45, 10],\n   {'slots': [['arrow', 10], ['Potion', 11], ['arrow', 10], ['Potion', 19], ['arrow', 10], ['Arrow', 0]],\n    'leftover': 20}),\n  ('partial repair boundary #1',\n   [[['Arrow', 5], None, ['Arrow', 20], ['arrow', 0], ['Potion', 0]], 'arrow', 7, 20],\n   {'slots': [['Arrow', 5], None, ['Arrow', 20], ['arrow', 7], ['Potion', 0]], 'leftover': 0}),\n  ('partial repair boundary #2',\n   [[None, None, ['arrow', 14], ['Arrow', 0], None, None], 'Arrow', 1, 5],\n   {'slots': [None, None, ['arrow', 14], ['Arrow', 1], None, None], 'leftover': 0}),\n  ('legacy overfull stack #1',\n   [[['Arrow', 25], None], 'Arrow', 3, 20],\n   {'slots': [['Arrow', 25], ['Arrow', 3]], 'leftover': 0}),\n  ('case distinct item #1', [[['arrow', 3]], 'Arrow', 2, 20], {'slots': [['arrow', 3]], 'leftover': 2}),\n  ('control #1', [[['Potion', 0]], 'Arrow', 45, 5], {'slots': [['Potion', 0]], 'leftover': 45})]]\nfor label, args, expected in cases[N-1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"1c64e7d66b4a1378ad45050571fb487dd29065e8bccf969eaadb0fcf62dc74e9","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(slots, item, qty, max_stack):\n    slots = [s if s is None else list(s) for s in slots]\n    left = qty\n    for s in slots:\n        if left == 0:\n            break\n        if s is not None and s[0] == item and s[1] < max_stack:\n            add = min(left, max_stack)\n            s[1] += add\n            left -= add\n    for i in range(len(slots)):\n        if left == 0:\n            break\n        if slots[i] is None:\n            add = min(left, max_stack)\n            slots[i] = [item, add]\n            left -= add\n    return {'slots': slots, 'leftover': left}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('two partial stacks #1',\n   [[['Arrow', 18], ['Arrow', 15], None], 'Arrow', 4, 20],\n   {'slots': [['Arrow', 20], ['Arrow', 17], None], 'leftover': 0}),\n  ('fault site top-up amount #1',\n   [[None, ['Arrow', 1], ['arrow', 1], ['Potion', 20], ['arrow', 19]], 'arrow', 20, 20],\n   {'slots': [None, ['Arrow', 1], ['arrow', 20], ['Potion', 20], ['arrow', 20]], 'leftover': 0}),\n  ('fault site top-up amount #2',\n   [[None, ['arrow', 5], None, None], 'arrow', 45, 10],\n   {'slots': [['arrow', 10], ['arrow', 10], ['arrow', 10], ['arrow', 10]], 'leftover': 10}),\n  ('partial repair boundary #1',\n   [[None, ['Potion', 0], ['Potion', 20], ['arrow', 1]], 'arrow', 1, 10],\n   {'slots': [None, ['Potion', 0], ['Potion', 20], ['arrow', 2]], 'leftover': 0}),\n  ('partial repair boundary #2',\n   [[['arrow', 5], ['Arrow', 1]], 'Arrow', 1, 20],\n   {'slots': [['arrow', 5], ['Arrow', 2]], 'leftover': 0}),\n  ('legacy overfull stack #1',\n   [[['Arrow', 25], None], 'Arrow', 3, 20],\n   {'slots': [['Arrow', 25], ['Arrow', 3]], 'leftover': 0}),\n  ('case distinct item #1', [[['arrow', 3]], 'Arrow', 2, 20], {'slots': [['arrow', 3]], 'leftover': 2}),\n  ('control #1',\n   [[['Arrow', 6], None, ['arrow', 5]], 'Potion', 0, 20],\n   {'slots': [['Arrow', 6], None, ['arrow', 5]], 'leftover': 0})],\n [('two partial stacks #1',\n   [[['Arrow', 18], ['Arrow', 15], None], 'Arrow', 4, 20],\n   {'slots': [['Arrow', 20], ['Arrow', 17], None], 'leftover': 0}),\n  ('fault site top-up amount #1',\n   [[None, ['arrow', 5], None, None], 'arrow', 45, 10],\n   {'slots': [['arrow', 10], ['arrow', 10], ['arrow', 10], ['arrow', 10]], 'leftover': 10}),\n  ('fault site top-up amount #2',\n   [[None, ['arrow', 1], ['Arrow', 19], ['arrow', 10], None], 'arrow', 20, 5],\n   {'slots': [['arrow', 5], ['arrow', 5], ['Arrow', 19], ['arrow', 10], ['arrow', 5]], 'leftover': 6}),\n  ('partial repair boundary #1',\n   [[['arrow', 5], ['Arrow', 1]], 'Arrow', 1, 20],\n   {'slots': [['arrow', 5], ['Arrow', 2]], 'leftover': 0}),\n  ('partial repair boundary #2',\n   [[['Arrow', 25], ['Arrow', 25], ['Potion', 1]], 'Potion', 7, 20],\n   {'slots': [['Arrow', 25], ['Arrow', 25], ['Potion', 8]], 'leftover': 0}),\n  ('legacy overfull stack #1',\n   [[['Arrow', 25], None], 'Arrow', 3, 20],\n   {'slots': [['Arrow', 25], ['Arrow', 3]], 'leftover': 0}),\n  ('case distinct item #1', [[['arrow', 3]], 'Arrow', 2, 20], {'slots': [['arrow', 3]], 'leftover': 2}),\n  ('control #1',\n   [[['Arrow', 6], None, ['arrow', 5]], 'Potion', 0, 20],\n   {'slots': [['Arrow', 6], None, ['arrow', 5]], 'leftover': 0})],\n [('two partial stacks #1',\n   [[['Arrow', 18], ['Arrow', 15], None], 'Arrow', 4, 20],\n   {'slots': [['Arrow', 20], ['Arrow', 17], None], 'leftover': 0}),\n  ('fault site top-up amount #1',\n   [[['Potion', 17], ['arrow', 1], ['Arrow', 0], ['arrow', 19]], 'arrow', 45, 20],\n   {'slots': [['Potion', 17], ['arrow', 20], ['Arrow', 0], ['arrow', 20]], 'leftover': 25}),\n  ('fault site top-up amount #2',\n   [[['Arrow', 5]], 'Arrow', 20, 20],\n   {'slots': [['Arrow', 20]], 'leftover': 5}),\n  ('partial repair boundary #1',\n   [[['arrow', 1], None, ['Potion', 5]], 'arrow', 7, 20],\n   {'slots': [['arrow', 8], None, ['Potion', 5]], 'leftover': 0}),\n  ('partial repair boundary #2',\n   [[['arrow', 20], ['Arrow', 0], ['Potion', 19]], 'Arrow', 7, 10],\n   {'slots': [['arrow', 20], ['Arrow', 7], ['Potion', 19]], 'leftover': 0}),\n  ('legacy overfull stack #1',\n   [[['Arrow', 25], None], 'Arrow', 3, 20],\n   {'slots': [['Arrow', 25], ['Arrow', 3]], 'leftover': 0}),\n  ('case distinct item #1', [[['arrow', 3]], 'Arrow', 2, 20], {'slots': [['arrow', 3]], 'leftover': 2}),\n  ('control #1',\n   [[['Arrow', 6], None, ['arrow', 5]], 'Potion', 0, 20],\n   {'slots': [['Arrow', 6], None, ['arrow', 5]], 'leftover': 0})],\n [('two partial stacks #1',\n   [[['Arrow', 18], ['Arrow', 15], None], 'Arrow', 4, 20],\n   {'slots': [['Arrow', 20], ['Arrow', 17], None], 'leftover': 0}),\n  ('fault site top-up amount #1',\n   [[['arrow', 25], None, ['Potion', 5], None, ['arrow', 20]], 'Potion', 7, 10],\n   {'slots': [['arrow', 25], ['Potion', 2], ['Potion', 10], None, ['arrow', 20]], 'leftover': 0}),\n  ('fault site top-up amount #2',\n   [[None, None, ['Arrow', 11], ['Potion', 10], ['Arrow', 25], None], 'Potion', 20, 20],\n   {'slots': [['Potion', 10], None, ['Arrow', 11], ['Potion', 20], ['Arrow', 25], None], 'leftover': 0}),\n  ('partial repair boundary #1',\n   [[['arrow', 5], ['Potion', 5], ['Potion', 1], ['Potion', 1], ['Arrow', 3]], 'arrow', 1, 20],\n   {'slots': [['arrow', 6], ['Potion', 5], ['Potion', 1], ['Potion', 1], ['Arrow', 3]], 'leftover': 0}),\n  ('partial repair boundary #2',\n   [[['arrow', 20], ['Arrow', 16], ['arrow', 20], None, None, ['Potion', 0]], 'Potion', 1, 20],\n   {'slots': [['arrow', 20], ['Arrow', 16], ['arrow', 20], None, None, ['Potion', 1]], 'leftover': 0}),\n  ('legacy overfull stack #1',\n   [[['Arrow', 25], None], 'Arrow', 3, 20],\n   {'slots': [['Arrow', 25], ['Arrow', 3]], 'leftover': 0}),\n  ('case distinct item #1', [[['arrow', 3]], 'Arrow', 2, 20], {'slots': [['arrow', 3]], 'leftover': 2}),\n  ('control #1',\n   [[None, ['Arrow', 16], ['arrow', 20], None, ['Arrow', 25], None], 'Potion', 20, 10],\n   {'slots': [['Potion', 10], ['Arrow', 16], ['arrow', 20], ['Potion', 10], ['Arrow', 25], None],\n    'leftover': 0})],\n [('two partial stacks #1',\n   [[['Arrow', 18], ['Arrow', 15], None], 'Arrow', 4, 20],\n   {'slots': [['Arrow', 20], ['Arrow', 17], None], 'leftover': 0}),\n  ('fault site top-up amount #1',\n   [[['Potion', 0], ['Arrow', 0], ['Arrow', 1]], 'Arrow', 45, 10],\n   {'slots': [['Potion', 0], ['Arrow', 10], ['Arrow', 10]], 'leftover': 26}),\n  ('fault site top-up amount #2',\n   [[None, ['Potion', 11], ['arrow', 5], ['Potion', 19], None, ['Arrow', 0]], 'arrow', 45, 10],\n   {'slots': [['arrow', 10], ['Potion', 11], ['arrow', 10], ['Potion', 19], ['arrow', 10], ['Arrow', 0]],\n    'leftover': 20}),\n  ('partial repair boundary #1',\n   [[['Arrow', 5], None, ['Arrow', 20], ['arrow', 0], ['Potion', 0]], 'arrow', 7, 20],\n   {'slots': [['Arrow', 5], None, ['Arrow', 20], ['arrow', 7], ['Potion', 0]], 'leftover': 0}),\n  ('partial repair boundary #2',\n   [[None, None, ['arrow', 14], ['Arrow', 0], None, None], 'Arrow', 1, 5],\n   {'slots': [None, None, ['arrow', 14], ['Arrow', 1], None, None], 'leftover': 0}),\n  ('legacy overfull stack #1',\n   [[['Arrow', 25], None], 'Arrow', 3, 20],\n   {'slots': [['Arrow', 25], ['Arrow', 3]], 'leftover': 0}),\n  ('case distinct item #1', [[['arrow', 3]], 'Arrow', 2, 20], {'slots': [['arrow', 3]], 'leftover': 2}),\n  ('control #1', [[['Potion', 0]], 'Arrow', 45, 5], {'slots': [['Potion', 0]], 'leftover': 45})]]\nfor label, args, expected in cases[N-1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"fixed":{"sha256":"7342b71235e00bae9aec787f2b06311054aa6f5901bede49878b3225542c0659","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(slots, item, qty, max_stack):\n    slots = [s if s is None else list(s) for s in slots]\n    left = qty\n    for s in slots:\n        if left == 0:\n            break\n        if s is not None and s[0] == item and s[1] < max_stack:\n            add = min(left, max_stack - s[1])\n            s[1] += add\n            left -= add\n    for i in range(len(slots)):\n        if left == 0:\n            break\n        if slots[i] is None:\n            add = min(left, max_stack)\n            slots[i] = [item, add]\n            left -= add\n    return {'slots': slots, 'leftover': left}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncases = [[('two partial stacks #1',\n   [[['Arrow', 18], ['Arrow', 15], None], 'Arrow', 4, 20],\n   {'slots': [['Arrow', 20], ['Arrow', 17], None], 'leftover': 0}),\n  ('fault site top-up amount #1',\n   [[None, ['Arrow', 1], ['arrow', 1], ['Potion', 20], ['arrow', 19]], 'arrow', 20, 20],\n   {'slots': [None, ['Arrow', 1], ['arrow', 20], ['Potion', 20], ['arrow', 20]], 'leftover': 0}),\n  ('fault site top-up amount #2',\n   [[None, ['arrow', 5], None, None], 'arrow', 45, 10],\n   {'slots': [['arrow', 10], ['arrow', 10], ['arrow', 10], ['arrow', 10]], 'leftover': 10}),\n  ('partial repair boundary #1',\n   [[None, ['Potion', 0], ['Potion', 20], ['arrow', 1]], 'arrow', 1, 10],\n   {'slots': [None, ['Potion', 0], ['Potion', 20], ['arrow', 2]], 'leftover': 0}),\n  ('partial repair boundary #2',\n   [[['arrow', 5], ['Arrow', 1]], 'Arrow', 1, 20],\n   {'slots': [['arrow', 5], ['Arrow', 2]], 'leftover': 0}),\n  ('legacy overfull stack #1',\n   [[['Arrow', 25], None], 'Arrow', 3, 20],\n   {'slots': [['Arrow', 25], ['Arrow', 3]], 'leftover': 0}),\n  ('case distinct item #1', [[['arrow', 3]], 'Arrow', 2, 20], {'slots': [['arrow', 3]], 'leftover': 2}),\n  ('control #1',\n   [[['Arrow', 6], None, ['arrow', 5]], 'Potion', 0, 20],\n   {'slots': [['Arrow', 6], None, ['arrow', 5]], 'leftover': 0})],\n [('two partial stacks #1',\n   [[['Arrow', 18], ['Arrow', 15], None], 'Arrow', 4, 20],\n   {'slots': [['Arrow', 20], ['Arrow', 17], None], 'leftover': 0}),\n  ('fault site top-up amount #1',\n   [[None, ['arrow', 5], None, None], 'arrow', 45, 10],\n   {'slots': [['arrow', 10], ['arrow', 10], ['arrow', 10], ['arrow', 10]], 'leftover': 10}),\n  ('fault site top-up amount #2',\n   [[None, ['arrow', 1], ['Arrow', 19], ['arrow', 10], None], 'arrow', 20, 5],\n   {'slots': [['arrow', 5], ['arrow', 5], ['Arrow', 19], ['arrow', 10], ['arrow', 5]], 'leftover': 6}),\n  ('partial repair boundary #1',\n   [[['arrow', 5], ['Arrow', 1]], 'Arrow', 1, 20],\n   {'slots': [['arrow', 5], ['Arrow', 2]], 'leftover': 0}),\n  ('partial repair boundary #2',\n   [[['Arrow', 25], ['Arrow', 25], ['Potion', 1]], 'Potion', 7, 20],\n   {'slots': [['Arrow', 25], ['Arrow', 25], ['Potion', 8]], 'leftover': 0}),\n  ('legacy overfull stack #1',\n   [[['Arrow', 25], None], 'Arrow', 3, 20],\n   {'slots': [['Arrow', 25], ['Arrow', 3]], 'leftover': 0}),\n  ('case distinct item #1', [[['arrow', 3]], 'Arrow', 2, 20], {'slots': [['arrow', 3]], 'leftover': 2}),\n  ('control #1',\n   [[['Arrow', 6], None, ['arrow', 5]], 'Potion', 0, 20],\n   {'slots': [['Arrow', 6], None, ['arrow', 5]], 'leftover': 0})],\n [('two partial stacks #1',\n   [[['Arrow', 18], ['Arrow', 15], None], 'Arrow', 4, 20],\n   {'slots': [['Arrow', 20], ['Arrow', 17], None], 'leftover': 0}),\n  ('fault site top-up amount #1',\n   [[['Potion', 17], ['arrow', 1], ['Arrow', 0], ['arrow', 19]], 'arrow', 45, 20],\n   {'slots': [['Potion', 17], ['arrow', 20], ['Arrow', 0], ['arrow', 20]], 'leftover': 25}),\n  ('fault site top-up amount #2',\n   [[['Arrow', 5]], 'Arrow', 20, 20],\n   {'slots': [['Arrow', 20]], 'leftover': 5}),\n  ('partial repair boundary #1',\n   [[['arrow', 1], None, ['Potion', 5]], 'arrow', 7, 20],\n   {'slots': [['arrow', 8], None, ['Potion', 5]], 'leftover': 0}),\n  ('partial repair boundary #2',\n   [[['arrow', 20], ['Arrow', 0], ['Potion', 19]], 'Arrow', 7, 10],\n   {'slots': [['arrow', 20], ['Arrow', 7], ['Potion', 19]], 'leftover': 0}),\n  ('legacy overfull stack #1',\n   [[['Arrow', 25], None], 'Arrow', 3, 20],\n   {'slots': [['Arrow', 25], ['Arrow', 3]], 'leftover': 0}),\n  ('case distinct item #1', [[['arrow', 3]], 'Arrow', 2, 20], {'slots': [['arrow', 3]], 'leftover': 2}),\n  ('control #1',\n   [[['Arrow', 6], None, ['arrow', 5]], 'Potion', 0, 20],\n   {'slots': [['Arrow', 6], None, ['arrow', 5]], 'leftover': 0})],\n [('two partial stacks #1',\n   [[['Arrow', 18], ['Arrow', 15], None], 'Arrow', 4, 20],\n   {'slots': [['Arrow', 20], ['Arrow', 17], None], 'leftover': 0}),\n  ('fault site top-up amount #1',\n   [[['arrow', 25], None, ['Potion', 5], None, ['arrow', 20]], 'Potion', 7, 10],\n   {'slots': [['arrow', 25], ['Potion', 2], ['Potion', 10], None, ['arrow', 20]], 'leftover': 0}),\n  ('fault site top-up amount #2',\n   [[None, None, ['Arrow', 11], ['Potion', 10], ['Arrow', 25], None], 'Potion', 20, 20],\n   {'slots': [['Potion', 10], None, ['Arrow', 11], ['Potion', 20], ['Arrow', 25], None], 'leftover': 0}),\n  ('partial repair boundary #1',\n   [[['arrow', 5], ['Potion', 5], ['Potion', 1], ['Potion', 1], ['Arrow', 3]], 'arrow', 1, 20],\n   {'slots': [['arrow', 6], ['Potion', 5], ['Potion', 1], ['Potion', 1], ['Arrow', 3]], 'leftover': 0}),\n  ('partial repair boundary #2',\n   [[['arrow', 20], ['Arrow', 16], ['arrow', 20], None, None, ['Potion', 0]], 'Potion', 1, 20],\n   {'slots': [['arrow', 20], ['Arrow', 16], ['arrow', 20], None, None, ['Potion', 1]], 'leftover': 0}),\n  ('legacy overfull stack #1',\n   [[['Arrow', 25], None], 'Arrow', 3, 20],\n   {'slots': [['Arrow', 25], ['Arrow', 3]], 'leftover': 0}),\n  ('case distinct item #1', [[['arrow', 3]], 'Arrow', 2, 20], {'slots': [['arrow', 3]], 'leftover': 2}),\n  ('control #1',\n   [[None, ['Arrow', 16], ['arrow', 20], None, ['Arrow', 25], None], 'Potion', 20, 10],\n   {'slots': [['Potion', 10], ['Arrow', 16], ['arrow', 20], ['Potion', 10], ['Arrow', 25], None],\n    'leftover': 0})],\n [('two partial stacks #1',\n   [[['Arrow', 18], ['Arrow', 15], None], 'Arrow', 4, 20],\n   {'slots': [['Arrow', 20], ['Arrow', 17], None], 'leftover': 0}),\n  ('fault site top-up amount #1',\n   [[['Potion', 0], ['Arrow', 0], ['Arrow', 1]], 'Arrow', 45, 10],\n   {'slots': [['Potion', 0], ['Arrow', 10], ['Arrow', 10]], 'leftover': 26}),\n  ('fault site top-up amount #2',\n   [[None, ['Potion', 11], ['arrow', 5], ['Potion', 19], None, ['Arrow', 0]], 'arrow', 45, 10],\n   {'slots': [['arrow', 10], ['Potion', 11], ['arrow', 10], ['Potion', 19], ['arrow', 10], ['Arrow', 0]],\n    'leftover': 20}),\n  ('partial repair boundary #1',\n   [[['Arrow', 5], None, ['Arrow', 20], ['arrow', 0], ['Potion', 0]], 'arrow', 7, 20],\n   {'slots': [['Arrow', 5], None, ['Arrow', 20], ['arrow', 7], ['Potion', 0]], 'leftover': 0}),\n  ('partial repair boundary #2',\n   [[None, None, ['arrow', 14], ['Arrow', 0], None, None], 'Arrow', 1, 5],\n   {'slots': [None, None, ['arrow', 14], ['Arrow', 1], None, None], 'leftover': 0}),\n  ('legacy overfull stack #1',\n   [[['Arrow', 25], None], 'Arrow', 3, 20],\n   {'slots': [['Arrow', 25], ['Arrow', 3]], 'leftover': 0}),\n  ('case distinct item #1', [[['arrow', 3]], 'Arrow', 2, 20], {'slots': [['arrow', 3]], 'leftover': 2}),\n  ('control #1', [[['Potion', 0]], 'Arrow', 45, 5], {'slots': [['Potion', 0]], 'leftover': 45})]]\nfor label, args, expected in cases[N-1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"Deterministic toy contract stipulated for this model; integer or exact arithmetic only, not a reproduction of any specific game engine. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-game-economy-crafting-balance-inventory-stacking-top-up-amount","generated_at":"2026-09-29T14:50:47.033569+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Game economies leak or destroy currency when one crafting or pricing rule is off by one boundary, rounding stage or state update; the defect is observable in exact integer outcomes.","repair":"Restore `min(left, max_stack - s[1])` at the top-up amount step.","root_cause":"The top-up amount ignores how many items the stack already holds.","sha256":"dd7b16af3f6153548f9928b032c17b5c85a4e72e506f1466213fdd0d0b564d3a","title":"Inventory stack insertion: Top-up ignores existing count · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":40.525,"exit_code":1,"observations":[{"actual":{"leftover":0,"slots":[["Arrow",20],["Arrow",20],["Arrow",-3]]},"check":"two partial stacks #1","expected":{"leftover":0,"slots":[["Arrow",20],["Arrow",17],null]},"passed":false},{"actual":{"leftover":0,"slots":[null,["Arrow",1],["arrow",20],["Potion",20],["arrow",20]]},"check":"fault site top-up amount #1","expected":{"leftover":0,"slots":[null,["Arrow",1],["arrow",20],["Potion",20],["arrow",20]]},"passed":true},{"actual":{"leftover":10,"slots":[["arrow",10],["arrow",10],["arrow",10],["arrow",10]]},"check":"fault site top-up amount #2","expected":{"leftover":10,"slots":[["arrow",10],["arrow",10],["arrow",10],["arrow",10]]},"passed":true},{"actual":{"leftover":0,"slots":[["arrow",-8],["Potion",0],["Potion",20],["arrow",10]]},"check":"partial repair boundary #1","expected":{"leftover":0,"slots":[null,["Potion",0],["Potion",20],["arrow",2]]},"passed":false},{"actual":{"leftover":-18,"slots":[["arrow",5],["Arrow",20]]},"check":"partial repair boundary #2","expected":{"leftover":0,"slots":[["arrow",5],["Arrow",2]]},"passed":false},{"actual":{"leftover":0,"slots":[["Arrow",25],["Arrow",3]]},"check":"legacy overfull stack #1","expected":{"leftover":0,"slots":[["Arrow",25],["Arrow",3]]},"passed":true},{"actual":{"leftover":2,"slots":[["arrow",3]]},"check":"case distinct item #1","expected":{"leftover":2,"slots":[["arrow",3]]},"passed":true},{"actual":{"leftover":0,"slots":[["Arrow",6],null,["arrow",5]]},"check":"control #1","expected":{"leftover":0,"slots":[["Arrow",6],null,["arrow",5]]},"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"two partial stacks #1\", \"actual\": {\"slots\": [[\"Arrow\", 20], [\"Arrow\", 20], [\"Arrow\", -3]], \"leftover\": 0}, \"expected\": {\"slots\": [[\"Arrow\", 20], [\"Arrow\", 17], null], \"leftover\": 0}, \"passed\": false}, {\"check\": \"fault site top-up amount #1\", \"actual\": {\"slots\": [null, [\"Arrow\", 1], [\"arrow\", 20], [\"Potion\", 20], [\"arrow\", 20]], \"leftover\": 0}, \"expected\": {\"slots\": [null, [\"Arrow\", 1], [\"arrow\", 20], [\"Potion\", 20], [\"arrow\", 20]], \"leftover\": 0}, \"passed\": true}, {\"check\": \"fault site top-up amount #2\", \"actual\": {\"slots\": [[\"arrow\", 10], [\"arrow\", 10], [\"arrow\", 10], [\"arrow\", 10]], \"leftover\": 10}, \"expected\": {\"slots\": [[\"arrow\", 10], [\"arrow\", 10], [\"arrow\", 10], [\"arrow\", 10]], \"leftover\": 10}, \"passed\": true}, {\"check\": \"partial repair boundary #1\", \"actual\": {\"slots\": [[\"arrow\", -8], [\"Potion\", 0], [\"Potion\", 20], [\"arrow\", 10]], \"leftover\": 0}, \"expected\": {\"slots\": [null, [\"Potion\", 0], [\"Potion\", 20], [\"arrow\", 2]], \"leftover\": 0}, \"passed\": false}, {\"check\": \"partial repair boundary #2\", \"actual\": {\"slots\": [[\"arrow\", 5], [\"Arrow\", 20]], \"leftover\": -18}, \"expected\": {\"slots\": [[\"arrow\", 5], [\"Arrow\", 2]], \"leftover\": 0}, \"passed\": false}, {\"check\": \"legacy overfull stack #1\", \"actual\": {\"slots\": [[\"Arrow\", 25], [\"Arrow\", 3]], \"leftover\": 0}, \"expected\": {\"slots\": [[\"Arrow\", 25], [\"Arrow\", 3]], \"leftover\": 0}, \"passed\": true}, {\"check\": \"case distinct item #1\", \"actual\": {\"slots\": [[\"arrow\", 3]], \"leftover\": 2}, \"expected\": {\"slots\": [[\"arrow\", 3]], \"leftover\": 2}, \"passed\": true}, {\"check\": \"control #1\", \"actual\": {\"slots\": [[\"Arrow\", 6], null, [\"arrow\", 5]], \"leftover\": 0}, \"expected\": {\"slots\": [[\"Arrow\", 6], null, [\"arrow\", 5]], \"leftover\": 0}, \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":45.414,"exit_code":1,"observations":[{"actual":{"leftover":0,"slots":[["Arrow",22],["Arrow",15],null]},"check":"two partial stacks #1","expected":{"leftover":0,"slots":[["Arrow",20],["Arrow",17],null]},"passed":false},{"actual":{"leftover":0,"slots":[null,["Arrow",1],["arrow",21],["Potion",20],["arrow",19]]},"check":"fault site top-up amount #1","expected":{"leftover":0,"slots":[null,["Arrow",1],["arrow",20],["Potion",20],["arrow",20]]},"passed":false},{"actual":{"leftover":5,"slots":[["arrow",10],["arrow",15],["arrow",10],["arrow",10]]},"check":"fault site top-up amount #2","expected":{"leftover":10,"slots":[["arrow",10],["arrow",10],["arrow",10],["arrow",10]]},"passed":false},{"actual":{"leftover":0,"slots":[null,["Potion",0],["Potion",20],["arrow",2]]},"check":"partial repair boundary #1","expected":{"leftover":0,"slots":[null,["Potion",0],["Potion",20],["arrow",2]]},"passed":true},{"actual":{"leftover":0,"slots":[["arrow",5],["Arrow",2]]},"check":"partial repair boundary #2","expected":{"leftover":0,"slots":[["arrow",5],["Arrow",2]]},"passed":true},{"actual":{"leftover":0,"slots":[["Arrow",25],["Arrow",3]]},"check":"legacy overfull stack #1","expected":{"leftover":0,"slots":[["Arrow",25],["Arrow",3]]},"passed":true},{"actual":{"leftover":2,"slots":[["arrow",3]]},"check":"case distinct item #1","expected":{"leftover":2,"slots":[["arrow",3]]},"passed":true},{"actual":{"leftover":0,"slots":[["Arrow",6],null,["arrow",5]]},"check":"control #1","expected":{"leftover":0,"slots":[["Arrow",6],null,["arrow",5]]},"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"two partial stacks #1\", \"actual\": {\"slots\": [[\"Arrow\", 22], [\"Arrow\", 15], null], \"leftover\": 0}, \"expected\": {\"slots\": [[\"Arrow\", 20], [\"Arrow\", 17], null], \"leftover\": 0}, \"passed\": false}, {\"check\": \"fault site top-up amount #1\", \"actual\": {\"slots\": [null, [\"Arrow\", 1], [\"arrow\", 21], [\"Potion\", 20], [\"arrow\", 19]], \"leftover\": 0}, \"expected\": {\"slots\": [null, [\"Arrow\", 1], [\"arrow\", 20], [\"Potion\", 20], [\"arrow\", 20]], \"leftover\": 0}, \"passed\": false}, {\"check\": \"fault site top-up amount #2\", \"actual\": {\"slots\": [[\"arrow\", 10], [\"arrow\", 15], [\"arrow\", 10], [\"arrow\", 10]], \"leftover\": 5}, \"expected\": {\"slots\": [[\"arrow\", 10], [\"arrow\", 10], [\"arrow\", 10], [\"arrow\", 10]], \"leftover\": 10}, \"passed\": false}, {\"check\": \"partial repair boundary #1\", \"actual\": {\"slots\": [null, [\"Potion\", 0], [\"Potion\", 20], [\"arrow\", 2]], \"leftover\": 0}, \"expected\": {\"slots\": [null, [\"Potion\", 0], [\"Potion\", 20], [\"arrow\", 2]], \"leftover\": 0}, \"passed\": true}, {\"check\": \"partial repair boundary #2\", \"actual\": {\"slots\": [[\"arrow\", 5], [\"Arrow\", 2]], \"leftover\": 0}, \"expected\": {\"slots\": [[\"arrow\", 5], [\"Arrow\", 2]], \"leftover\": 0}, \"passed\": true}, {\"check\": \"legacy overfull stack #1\", \"actual\": {\"slots\": [[\"Arrow\", 25], [\"Arrow\", 3]], \"leftover\": 0}, \"expected\": {\"slots\": [[\"Arrow\", 25], [\"Arrow\", 3]], \"leftover\": 0}, \"passed\": true}, {\"check\": \"case distinct item #1\", \"actual\": {\"slots\": [[\"arrow\", 3]], \"leftover\": 2}, \"expected\": {\"slots\": [[\"arrow\", 3]], \"leftover\": 2}, \"passed\": true}, {\"check\": \"control #1\", \"actual\": {\"slots\": [[\"Arrow\", 6], null, [\"arrow\", 5]], \"leftover\": 0}, \"expected\": {\"slots\": [[\"Arrow\", 6], null, [\"arrow\", 5]], \"leftover\": 0}, \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":40.254,"exit_code":0,"observations":[{"actual":{"leftover":0,"slots":[["Arrow",20],["Arrow",17],null]},"check":"two partial stacks #1","expected":{"leftover":0,"slots":[["Arrow",20],["Arrow",17],null]},"passed":true},{"actual":{"leftover":0,"slots":[null,["Arrow",1],["arrow",20],["Potion",20],["arrow",20]]},"check":"fault site top-up amount #1","expected":{"leftover":0,"slots":[null,["Arrow",1],["arrow",20],["Potion",20],["arrow",20]]},"passed":true},{"actual":{"leftover":10,"slots":[["arrow",10],["arrow",10],["arrow",10],["arrow",10]]},"check":"fault site top-up amount #2","expected":{"leftover":10,"slots":[["arrow",10],["arrow",10],["arrow",10],["arrow",10]]},"passed":true},{"actual":{"leftover":0,"slots":[null,["Potion",0],["Potion",20],["arrow",2]]},"check":"partial repair boundary #1","expected":{"leftover":0,"slots":[null,["Potion",0],["Potion",20],["arrow",2]]},"passed":true},{"actual":{"leftover":0,"slots":[["arrow",5],["Arrow",2]]},"check":"partial repair boundary #2","expected":{"leftover":0,"slots":[["arrow",5],["Arrow",2]]},"passed":true},{"actual":{"leftover":0,"slots":[["Arrow",25],["Arrow",3]]},"check":"legacy overfull stack #1","expected":{"leftover":0,"slots":[["Arrow",25],["Arrow",3]]},"passed":true},{"actual":{"leftover":2,"slots":[["arrow",3]]},"check":"case distinct item #1","expected":{"leftover":2,"slots":[["arrow",3]]},"passed":true},{"actual":{"leftover":0,"slots":[["Arrow",6],null,["arrow",5]]},"check":"control #1","expected":{"leftover":0,"slots":[["Arrow",6],null,["arrow",5]]},"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"two partial stacks #1\", \"actual\": {\"slots\": [[\"Arrow\", 20], [\"Arrow\", 17], null], \"leftover\": 0}, \"expected\": {\"slots\": [[\"Arrow\", 20], [\"Arrow\", 17], null], \"leftover\": 0}, \"passed\": true}, {\"check\": \"fault site top-up amount #1\", \"actual\": {\"slots\": [null, [\"Arrow\", 1], [\"arrow\", 20], [\"Potion\", 20], [\"arrow\", 20]], \"leftover\": 0}, \"expected\": {\"slots\": [null, [\"Arrow\", 1], [\"arrow\", 20], [\"Potion\", 20], [\"arrow\", 20]], \"leftover\": 0}, \"passed\": true}, {\"check\": \"fault site top-up amount #2\", \"actual\": {\"slots\": [[\"arrow\", 10], [\"arrow\", 10], [\"arrow\", 10], [\"arrow\", 10]], \"leftover\": 10}, \"expected\": {\"slots\": [[\"arrow\", 10], [\"arrow\", 10], [\"arrow\", 10], [\"arrow\", 10]], \"leftover\": 10}, \"passed\": true}, {\"check\": \"partial repair boundary #1\", \"actual\": {\"slots\": [null, [\"Potion\", 0], [\"Potion\", 20], [\"arrow\", 2]], \"leftover\": 0}, \"expected\": {\"slots\": [null, [\"Potion\", 0], [\"Potion\", 20], [\"arrow\", 2]], \"leftover\": 0}, \"passed\": true}, {\"check\": \"partial repair boundary #2\", \"actual\": {\"slots\": [[\"arrow\", 5], [\"Arrow\", 2]], \"leftover\": 0}, \"expected\": {\"slots\": [[\"arrow\", 5], [\"Arrow\", 2]], \"leftover\": 0}, \"passed\": true}, {\"check\": \"legacy overfull stack #1\", \"actual\": {\"slots\": [[\"Arrow\", 25], [\"Arrow\", 3]], \"leftover\": 0}, \"expected\": {\"slots\": [[\"Arrow\", 25], [\"Arrow\", 3]], \"leftover\": 0}, \"passed\": true}, {\"check\": \"case distinct item #1\", \"actual\": {\"slots\": [[\"arrow\", 3]], \"leftover\": 2}, \"expected\": {\"slots\": [[\"arrow\", 3]], \"leftover\": 2}, \"passed\": true}, {\"check\": \"control #1\", \"actual\": {\"slots\": [[\"Arrow\", 6], null, [\"arrow\", 5]], \"leftover\": 0}, \"expected\": {\"slots\": [[\"Arrow\", 6], null, [\"arrow\", 5]], \"leftover\": 0}, \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}