{"abstract":"Having six eggs for a two-egg recipe lists \"-4\" eggs to buy.","category":"Recipe scaling and nutrition","checks":8,"contract":"Rows [name, qty, unit]. Names normalize: trim, lower, \"-oes\" -> drop \"es\", \"-ies\" -> \"y\", other trailing \"s\" dropped unless \"ss\". Volume (tsp=1, tbsp=3, cup=48 tsp), mass (g, kg=1000 g) and other units aggregate separately per name. Pantry {name: [qty, unit]} subtracts from the same name and dimension, never below 0. Output sorted by (name, dimension) as [name, str(qty), unit], skipping zero totals; volume shows cup if >=12 tsp, else tbsp if >=3 tsp, else tsp; mass shows kg if >=1000 g.","contract_signature":"recipes, pantry","evaluation_group":"w2-recipe_scaling_and_nutrition-shopping-list","failed_approach":"abs() turns a surplus of four eggs into four eggs to buy.","family":"w2-recipe_scaling_and_nutrition-shopping-list-pantry-subtraction-floor","id":"FA-97136","implementations":{"attempt":{"sha256":"bfbaa8b0c68d006b43db1df9e4ba91cc378511c26b79d3ba4db8eef1c7686131","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(recipes, pantry):\n    VOL = {'tsp': 1, 'tbsp': 3, 'cup': 48}\n    MASS = {'g': 1, 'kg': 1000}\n    def norm(n):\n        n = n.strip().lower()\n        if n.endswith('oes'):\n            return n[:-2]\n        if n.endswith('ies'):\n            return n[:-3] + 'y'\n        if n.endswith('s') and not n.endswith('ss'):\n            return n[:-1]\n        return n\n    def base(q, u):\n        if u in VOL:\n            return 'volume', Fraction(q) * VOL[u]\n        if u in MASS:\n            return 'mass', Fraction(q) * MASS[u]\n        return u, Fraction(q)\n    tot = {}\n    for recipe in recipes:\n        for name, q, u in recipe:\n            dim, v = base(q, u)\n            k = (norm(name), dim)\n            tot[k] = tot.get(k, 0) + v\n    for name, (q, u) in pantry.items():\n        dim, v = base(q, u)\n        pk = (norm(name), dim)\n        if pk in tot:\n            tot[pk] = abs(tot[pk] - v)\n    out = []\n    for (name, dim), v in sorted(tot.items()):\n        if v == 0:\n            continue\n        if dim == 'volume':\n            unit, v2 = ('cup', v / 48) if v >= 12 else ('tbsp', v / 3) if v >= 3 else ('tsp', v)\n        elif dim == 'mass':\n            unit, v2 = ('kg', v / 1000) if v >= 1000 else ('g', v)\n        else:\n            unit, v2 = dim, v\n        out.append([name, str(v2), unit])\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['single recipe', [[[['flour', '1', 'cup']]], {}], [['flour', '1', 'cup']]],\n  ['merge plurals', [[[['tomatoes', '2', 'each']], [['Tomato', '1', 'each']]], {}],\n   [['tomato', '3', 'each']]],\n  ['pantry covers all', [[[['eggs', '2', 'each']]], {'egg': ['6', 'each']}], []],\n  ['regression: pantry subtraction floor',\n   [[[['peas', '1/4', 'each'], ['eggs', '1', 'kg'], ['grape', '3/4', 'tsp']]], {'peas': ['2', 'each']}],\n   [['egg', '1', 'kg'], ['grape', '3/4', 'tsp']]],\n  ['repair check: pantry subtraction floor',\n   [[[['watercress', '3/4', 'cup'], ['peas', '2', 'each'], ['grapes', '1/2', 'g'], ['flour', '1', 'kg']],\n     [['peas', '1/2', 'tbsp'], ['tomatoes', '1/2', 'kg'], ['watercress', '3/4', 'tsp'],\n      ['peas', '4', 'each']],\n     [['tomatoes', '1/2', 'cup'], ['potatoes', '1/4', 'tsp'], ['egg', '1/3', 'cup'], ['flour', '4', 'tsp']]],\n    {'berries': ['1/3', 'each'], 'tomatoes': ['3', 'cup']}],\n   [['egg', '1/3', 'cup'], ['flour', '1', 'kg'], ['flour', '4/3', 'tbsp'], ['grape', '1/2', 'g'],\n    ['pea', '6', 'each'], ['pea', '3/2', 'tsp'], ['potato', '1/4', 'tsp'], ['tomato', '500', 'g'],\n    ['watercress', '49/64', 'cup']]],\n  ['generated control 1',\n   [[[['egg', '1/4', 'g'], ['grape', '4', 'tsp']],\n     [['egg', '4', 'tsp'], ['watercress', '4', 'g'], ['egg', '1', 'kg'], ['berry', '4', 'kg']],\n     [['grapes', '1/4', 'cup'], ['watercress', '1/2', 'tsp'], ['sugar ', '3/4', 'g']]],\n    {'egg': ['1/2', 'tsp']}],\n   [['berry', '4', 'kg'], ['egg', '4001/4000', 'kg'], ['egg', '7/6', 'tbsp'], ['grape', '1/3', 'cup'],\n    ['sugar', '3/4', 'g'], ['watercress', '4', 'g'], ['watercress', '1/2', 'tsp']]],\n  ['generated control 2',\n   [[[['potatoes', '1/4', 'g'], ['tomatoes', '4', 'tsp']],\n     [['potatoes', '2', 'kg'], ['berry', '3/4', 'cup']]],\n    {'grapes': ['2', 'kg']}],\n   [['berry', '3/4', 'cup'], ['potato', '8001/4000', 'kg'], ['tomato', '4/3', 'tbsp']]],\n  ['generated control 3',\n   [[[['peas', '1/3', 'g'], ['flour', '1', 'tsp']]], {'eggs': ['1', 'tbsp'], 'tomatoes': ['2', 'each']}],\n   [['flour', '1', 'tsp'], ['pea', '1/3', 'g']]]],\n [['merge plurals', [[[['tomatoes', '2', 'each']], [['Tomato', '1', 'each']]], {}],\n   [['tomato', '3', 'each']]],\n  ['pantry covers all', [[[['eggs', '2', 'each']]], {'egg': ['6', 'each']}], []],\n  ['watercress keeps ss', [[[['watercress', '100', 'g']]], {}], [['watercress', '100', 'g']]],\n  ['regression: pantry subtraction floor',\n   [[[['berries', '1/4', 'tbsp'], ['berries', '1/2', 'kg'], ['watercress', '1', 'cup'],\n      ['watercress', '3', 'tbsp']],\n     [['flour', '1', 'kg'], ['grape', '1/2', 'tsp'], ['sugar ', '3/4', 'tsp']]],\n    {'eggs': ['2', 'tbsp'], 'grapes': ['1', 'cup']}],\n   [['berry', '500', 'g'], ['berry', '3/4', 'tsp'], ['flour', '1', 'kg'], ['sugar', '3/4', 'tsp'],\n    ['watercress', '19/16', 'cup']]],\n  ['repair check: pantry subtraction floor',\n   [[[['peas', '2', 'kg'], ['grapes', '3/4', 'cup'], ['berry', '3/4', 'each'], ['flour', '3', 'g']],\n     [['egg', '2', 'tbsp'], ['Tomato', '3/4', 'each']]],\n    {'eggs': ['1/4', 'cup'], 'grape': ['1/2', 'cup']}],\n   [['berry', '3/4', 'each'], ['flour', '3', 'g'], ['grape', '1/4', 'cup'], ['pea', '2', 'kg'],\n    ['tomato', '3/4', 'each']]],\n  ['generated control 1',\n   [[[['egg', '2', 'tsp'], ['egg', '2', 'cup']], [['Tomato', '1/2', 'cup'], ['berries', '1/3', 'each']],\n     [['grapes', '1/2', 'each'], ['berry', '2', 'cup'], ['eggs', '3/4', 'tbsp'], ['flour', '1/3', 'g']]],\n    {'grape': ['3', 'tbsp']}],\n   [['berry', '1/3', 'each'], ['berry', '2', 'cup'], ['egg', '401/192', 'cup'], ['flour', '1/3', 'g'],\n    ['grape', '1/2', 'each'], ['tomato', '1/2', 'cup']]],\n  ['generated control 2',\n   [[[['egg', '3', 'cup']], [['watercress', '2', 'tbsp'], ['peas', '3', 'each']]], {'sugar ': ['1', 'g']}],\n   [['egg', '3', 'cup'], ['pea', '3', 'each'], ['watercress', '2', 'tbsp']]],\n  ['generated control 3',\n   [[[['berries', '1/3', 'tbsp'], ['Tomato', '1/3', 'tsp'], ['peas', '1/3', 'tbsp']]], {}],\n   [['berry', '1', 'tsp'], ['pea', '1', 'tsp'], ['tomato', '1/3', 'tsp']]]],\n [['pantry covers all', [[[['eggs', '2', 'each']]], {'egg': ['6', 'each']}], []],\n  ['watercress keeps ss', [[[['watercress', '100', 'g']]], {}], [['watercress', '100', 'g']]],\n  ['single recipe', [[[['flour', '1', 'cup']]], {}], [['flour', '1', 'cup']]],\n  ['regression: pantry subtraction floor',\n   [[[['tomatoes', '1/4', 'kg'], ['tomatoes', '1', 'tbsp'], ['potatoes', '1', 'kg'], ['peas', '1', 'each']],\n     [['berry', '1/2', 'each']], [['eggs', '1/2', 'kg'], ['grapes', '1', 'kg']]],\n    {'berries': ['3/4', 'each'], 'watercress': ['1/2', 'kg']}],\n   [['egg', '500', 'g'], ['grape', '1', 'kg'], ['pea', '1', 'each'], ['potato', '1', 'kg'],\n    ['tomato', '250', 'g'], ['tomato', '1', 'tbsp']]],\n  ['repair check: pantry subtraction floor',\n   [[[['flour', '3', 'each'], ['sugar ', '1/3', 'tbsp']], [['grape', '3/4', 'kg'], ['berry', '2', 'each']],\n     [['berry', '1', 'cup']]],\n    {'flour': ['2', 'cup'], 'sugar ': ['3', 'tbsp']}],\n   [['berry', '2', 'each'], ['berry', '1', 'cup'], ['flour', '3', 'each'], ['grape', '750', 'g']]],\n  ['generated control 1',\n   [[[['flour', '1/2', 'each'], ['eggs', '1/2', 'kg']], [['flour', '2', 'cup']],\n     [['berry', '3', 'cup'], ['peas', '3', 'tbsp']]],\n    {'berry': ['4', 'tsp'], 'egg': ['1/3', 'each']}],\n   [['berry', '35/12', 'cup'], ['egg', '500', 'g'], ['flour', '1/2', 'each'], ['flour', '2', 'cup'],\n    ['pea', '3', 'tbsp']]],\n  ['generated control 2',\n   [[[['grape', '3', 'kg'], ['grape', '3/4', 'kg']],\n     [['sugar ', '1', 'kg'], ['tomatoes', '1/2', 'tbsp'], ['potatoes', '2', 'cup'],\n      ['watercress', '1/3', 'kg']]],\n    {}],\n   [['grape', '15/4', 'kg'], ['potato', '2', 'cup'], ['sugar', '1', 'kg'], ['tomato', '3/2', 'tsp'],\n    ['watercress', '1000/3', 'g']]],\n  ['generated control 3',\n   [[[['grapes', '3', 'each'], ['potatoes', '1', 'tbsp'], ['sugar ', '1/2', 'g']]], {}],\n   [['grape', '3', 'each'], ['potato', '1', 'tbsp'], ['sugar', '1/2', 'g']]]],\n [['watercress keeps ss', [[[['watercress', '100', 'g']]], {}], [['watercress', '100', 'g']]],\n  ['single recipe', [[[['flour', '1', 'cup']]], {}], [['flour', '1', 'cup']]],\n  ['merge plurals', [[[['tomatoes', '2', 'each']], [['Tomato', '1', 'each']]], {}],\n   [['tomato', '3', 'each']]],\n  ['regression: pantry subtraction floor',\n   [[[['Tomato', '1/2', 'tbsp'], ['sugar ', '1', 'each'], ['watercress', '1', 'cup'],\n      ['flour', '1/2', 'each']],\n     [['grape', '4', 'kg']]],\n    {'Tomato': ['4', 'cup'], 'grapes': ['3', 'each']}],\n   [['flour', '1/2', 'each'], ['grape', '4', 'kg'], ['sugar', '1', 'each'], ['watercress', '1', 'cup']]],\n  ['repair check: pantry subtraction floor',\n   [[[['berry', '2', 'g'], ['tomatoes', '1', 'tbsp'], ['peas', '3', 'kg'], ['Tomato', '3', 'tbsp']],\n     [['watercress', '4', 'tsp']], [['eggs', '3/4', 'tsp'], ['flour', '1/2', 'g']]],\n    {'grapes': ['3/4', 'tbsp'], 'watercress': ['4', 'tbsp']}],\n   [['berry', '2', 'g'], ['egg', '3/4', 'tsp'], ['flour', '1/2', 'g'], ['pea', '3', 'kg'],\n    ['tomato', '1/4', 'cup']]],\n  ['generated control 1',\n   [[[['sugar ', '2', 'each'], ['watercress', '3/4', 'tsp'], ['sugar ', '1', 'kg'], ['tomatoes', '2', 'kg']]],\n    {}],\n   [['sugar', '2', 'each'], ['sugar', '1', 'kg'], ['tomato', '2', 'kg'], ['watercress', '3/4', 'tsp']]],\n  ['generated control 2',\n   [[[['tomatoes', '1/2', 'kg'], ['potatoes', '3/4', 'g'], ['sugar ', '3/4', 'g'], ['Tomato', '4', 'tsp']],\n     [['berries', '2', 'tbsp']]],\n    {}],\n   [['berry', '2', 'tbsp'], ['potato', '3/4', 'g'], ['sugar', '3/4', 'g'], ['tomato', '500', 'g'],\n    ['tomato', '4/3', 'tbsp']]],\n  ['generated control 3',\n   [[[['peas', '3', 'kg'], ['potatoes', '3', 'cup']]], {'Tomato': ['1/4', 'tbsp'], 'peas': ['1', 'cup']}],\n   [['pea', '3', 'kg'], ['potato', '3', 'cup']]]],\n [['single recipe', [[[['flour', '1', 'cup']]], {}], [['flour', '1', 'cup']]],\n  ['merge plurals', [[[['tomatoes', '2', 'each']], [['Tomato', '1', 'each']]], {}],\n   [['tomato', '3', 'each']]],\n  ['pantry covers all', [[[['eggs', '2', 'each']]], {'egg': ['6', 'each']}], []],\n  ['regression: pantry subtraction floor',\n   [[[['berries', '3/4', 'tbsp'], ['potatoes', '1/2', 'g']],\n     [['flour', '2', 'g'], ['grapes', '1/3', 'g'], ['grape', '1/3', 'each']],\n     [['sugar ', '2', 'tsp'], ['eggs', '2', 'each'], ['peas', '1', 'cup'], ['watercress', '4', 'tsp']]],\n    {'sugar ': ['3', 'tsp']}],\n   [['berry', '9/4', 'tsp'], ['egg', '2', 'each'], ['flour', '2', 'g'], ['grape', '1/3', 'each'],\n    ['grape', '1/3', 'g'], ['pea', '1', 'cup'], ['potato', '1/2', 'g'], ['watercress', '4/3', 'tbsp']]],\n  ['repair check: pantry subtraction floor',\n   [[[['tomatoes', '2', 'g'], ['grape', '3', 'tsp'], ['egg', '2', 'g']],\n     [['watercress', '1/3', 'g'], ['grapes', '4', 'kg'], ['grape', '2', 'kg'], ['watercress', '1/2', 'tsp']]],\n    {'Tomato': ['4', 'g'], 'eggs': ['1/4', 'each']}],\n   [['egg', '2', 'g'], ['grape', '6', 'kg'], ['grape', '1', 'tbsp'], ['watercress', '1/3', 'g'],\n    ['watercress', '1/2', 'tsp']]],\n  ['generated control 1',\n   [[[['grape', '1/4', 'each'], ['peas', '4', 'g'], ['sugar ', '2', 'tbsp'], ['tomatoes', '1/2', 'each']],\n     [['potatoes', '1/3', 'g'], ['potatoes', '1/2', 'each'], ['Tomato', '1/2', 'tsp'],\n      ['watercress', '3', 'tsp']],\n     [['grapes', '3/4', 'tsp']]],\n    {'berries': ['4', 'tsp'], 'egg': ['2', 'tbsp']}],\n   [['grape', '1/4', 'each'], ['grape', '3/4', 'tsp'], ['pea', '4', 'g'], ['potato', '1/2', 'each'],\n    ['potato', '1/3', 'g'], ['sugar', '2', 'tbsp'], ['tomato', '1/2', 'each'], ['tomato', '1/2', 'tsp'],\n    ['watercress', '1', 'tbsp']]],\n  ['generated control 2',\n   [[[['grapes', '4', 'tbsp'], ['eggs', '1/3', 'tbsp'], ['egg', '3/4', 'kg']], [['sugar ', '3', 'kg']]], {}],\n   [['egg', '750', 'g'], ['egg', '1', 'tsp'], ['grape', '1/4', 'cup'], ['sugar', '3', 'kg']]],\n  ['generated control 3',\n   [[[['peas', '1/4', 'each'], ['sugar ', '4', 'each'], ['peas', '4', 'kg'], ['potatoes', '1/3', 'kg']],\n     [['grape', '1/3', 'cup']]],\n    {'grape': ['3/4', 'tsp']}],\n   [['grape', '61/192', 'cup'], ['pea', '1/4', 'each'], ['pea', '4', 'kg'], ['potato', '1000/3', 'g'],\n    ['sugar', '4', 'each']]]]]\nfor label, args, expected in fixtures[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":"5e7bb521aa6c29a7c106c7e1a506dc42060556ebccfb4ffd11226acfdf17bb06","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport math\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(recipes, pantry):\n    VOL = {'tsp': 1, 'tbsp': 3, 'cup': 48}\n    MASS = {'g': 1, 'kg': 1000}\n    def norm(n):\n        n = n.strip().lower()\n        if n.endswith('oes'):\n            return n[:-2]\n        if n.endswith('ies'):\n            return n[:-3] + 'y'\n        if n.endswith('s') and not n.endswith('ss'):\n            return n[:-1]\n        return n\n    def base(q, u):\n        if u in VOL:\n            return 'volume', Fraction(q) * VOL[u]\n        if u in MASS:\n            return 'mass', Fraction(q) * MASS[u]\n        return u, Fraction(q)\n    tot = {}\n    for recipe in recipes:\n        for name, q, u in recipe:\n            dim, v = base(q, u)\n            k = (norm(name), dim)\n            tot[k] = tot.get(k, 0) + v\n    for name, (q, u) in pantry.items():\n        dim, v = base(q, u)\n        pk = (norm(name), dim)\n        if pk in tot:\n            tot[pk] = tot[pk] - v\n    out = []\n    for (name, dim), v in sorted(tot.items()):\n        if v == 0:\n            continue\n        if dim == 'volume':\n            unit, v2 = ('cup', v / 48) if v >= 12 else ('tbsp', v / 3) if v >= 3 else ('tsp', v)\n        elif dim == 'mass':\n            unit, v2 = ('kg', v / 1000) if v >= 1000 else ('g', v)\n        else:\n            unit, v2 = dim, v\n        out.append([name, str(v2), unit])\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['single recipe', [[[['flour', '1', 'cup']]], {}], [['flour', '1', 'cup']]],\n  ['merge plurals', [[[['tomatoes', '2', 'each']], [['Tomato', '1', 'each']]], {}],\n   [['tomato', '3', 'each']]],\n  ['pantry covers all', [[[['eggs', '2', 'each']]], {'egg': ['6', 'each']}], []],\n  ['regression: pantry subtraction floor',\n   [[[['peas', '1/4', 'each'], ['eggs', '1', 'kg'], ['grape', '3/4', 'tsp']]], {'peas': ['2', 'each']}],\n   [['egg', '1', 'kg'], ['grape', '3/4', 'tsp']]],\n  ['repair check: pantry subtraction floor',\n   [[[['watercress', '3/4', 'cup'], ['peas', '2', 'each'], ['grapes', '1/2', 'g'], ['flour', '1', 'kg']],\n     [['peas', '1/2', 'tbsp'], ['tomatoes', '1/2', 'kg'], ['watercress', '3/4', 'tsp'],\n      ['peas', '4', 'each']],\n     [['tomatoes', '1/2', 'cup'], ['potatoes', '1/4', 'tsp'], ['egg', '1/3', 'cup'], ['flour', '4', 'tsp']]],\n    {'berries': ['1/3', 'each'], 'tomatoes': ['3', 'cup']}],\n   [['egg', '1/3', 'cup'], ['flour', '1', 'kg'], ['flour', '4/3', 'tbsp'], ['grape', '1/2', 'g'],\n    ['pea', '6', 'each'], ['pea', '3/2', 'tsp'], ['potato', '1/4', 'tsp'], ['tomato', '500', 'g'],\n    ['watercress', '49/64', 'cup']]],\n  ['generated control 1',\n   [[[['egg', '1/4', 'g'], ['grape', '4', 'tsp']],\n     [['egg', '4', 'tsp'], ['watercress', '4', 'g'], ['egg', '1', 'kg'], ['berry', '4', 'kg']],\n     [['grapes', '1/4', 'cup'], ['watercress', '1/2', 'tsp'], ['sugar ', '3/4', 'g']]],\n    {'egg': ['1/2', 'tsp']}],\n   [['berry', '4', 'kg'], ['egg', '4001/4000', 'kg'], ['egg', '7/6', 'tbsp'], ['grape', '1/3', 'cup'],\n    ['sugar', '3/4', 'g'], ['watercress', '4', 'g'], ['watercress', '1/2', 'tsp']]],\n  ['generated control 2',\n   [[[['potatoes', '1/4', 'g'], ['tomatoes', '4', 'tsp']],\n     [['potatoes', '2', 'kg'], ['berry', '3/4', 'cup']]],\n    {'grapes': ['2', 'kg']}],\n   [['berry', '3/4', 'cup'], ['potato', '8001/4000', 'kg'], ['tomato', '4/3', 'tbsp']]],\n  ['generated control 3',\n   [[[['peas', '1/3', 'g'], ['flour', '1', 'tsp']]], {'eggs': ['1', 'tbsp'], 'tomatoes': ['2', 'each']}],\n   [['flour', '1', 'tsp'], ['pea', '1/3', 'g']]]],\n [['merge plurals', [[[['tomatoes', '2', 'each']], [['Tomato', '1', 'each']]], {}],\n   [['tomato', '3', 'each']]],\n  ['pantry covers all', [[[['eggs', '2', 'each']]], {'egg': ['6', 'each']}], []],\n  ['watercress keeps ss', [[[['watercress', '100', 'g']]], {}], [['watercress', '100', 'g']]],\n  ['regression: pantry subtraction floor',\n   [[[['berries', '1/4', 'tbsp'], ['berries', '1/2', 'kg'], ['watercress', '1', 'cup'],\n      ['watercress', '3', 'tbsp']],\n     [['flour', '1', 'kg'], ['grape', '1/2', 'tsp'], ['sugar ', '3/4', 'tsp']]],\n    {'eggs': ['2', 'tbsp'], 'grapes': ['1', 'cup']}],\n   [['berry', '500', 'g'], ['berry', '3/4', 'tsp'], ['flour', '1', 'kg'], ['sugar', '3/4', 'tsp'],\n    ['watercress', '19/16', 'cup']]],\n  ['repair check: pantry subtraction floor',\n   [[[['peas', '2', 'kg'], ['grapes', '3/4', 'cup'], ['berry', '3/4', 'each'], ['flour', '3', 'g']],\n     [['egg', '2', 'tbsp'], ['Tomato', '3/4', 'each']]],\n    {'eggs': ['1/4', 'cup'], 'grape': ['1/2', 'cup']}],\n   [['berry', '3/4', 'each'], ['flour', '3', 'g'], ['grape', '1/4', 'cup'], ['pea', '2', 'kg'],\n    ['tomato', '3/4', 'each']]],\n  ['generated control 1',\n   [[[['egg', '2', 'tsp'], ['egg', '2', 'cup']], [['Tomato', '1/2', 'cup'], ['berries', '1/3', 'each']],\n     [['grapes', '1/2', 'each'], ['berry', '2', 'cup'], ['eggs', '3/4', 'tbsp'], ['flour', '1/3', 'g']]],\n    {'grape': ['3', 'tbsp']}],\n   [['berry', '1/3', 'each'], ['berry', '2', 'cup'], ['egg', '401/192', 'cup'], ['flour', '1/3', 'g'],\n    ['grape', '1/2', 'each'], ['tomato', '1/2', 'cup']]],\n  ['generated control 2',\n   [[[['egg', '3', 'cup']], [['watercress', '2', 'tbsp'], ['peas', '3', 'each']]], {'sugar ': ['1', 'g']}],\n   [['egg', '3', 'cup'], ['pea', '3', 'each'], ['watercress', '2', 'tbsp']]],\n  ['generated control 3',\n   [[[['berries', '1/3', 'tbsp'], ['Tomato', '1/3', 'tsp'], ['peas', '1/3', 'tbsp']]], {}],\n   [['berry', '1', 'tsp'], ['pea', '1', 'tsp'], ['tomato', '1/3', 'tsp']]]],\n [['pantry covers all', [[[['eggs', '2', 'each']]], {'egg': ['6', 'each']}], []],\n  ['watercress keeps ss', [[[['watercress', '100', 'g']]], {}], [['watercress', '100', 'g']]],\n  ['single recipe', [[[['flour', '1', 'cup']]], {}], [['flour', '1', 'cup']]],\n  ['regression: pantry subtraction floor',\n   [[[['tomatoes', '1/4', 'kg'], ['tomatoes', '1', 'tbsp'], ['potatoes', '1', 'kg'], ['peas', '1', 'each']],\n     [['berry', '1/2', 'each']], [['eggs', '1/2', 'kg'], ['grapes', '1', 'kg']]],\n    {'berries': ['3/4', 'each'], 'watercress': ['1/2', 'kg']}],\n   [['egg', '500', 'g'], ['grape', '1', 'kg'], ['pea', '1', 'each'], ['potato', '1', 'kg'],\n    ['tomato', '250', 'g'], ['tomato', '1', 'tbsp']]],\n  ['repair check: pantry subtraction floor',\n   [[[['flour', '3', 'each'], ['sugar ', '1/3', 'tbsp']], [['grape', '3/4', 'kg'], ['berry', '2', 'each']],\n     [['berry', '1', 'cup']]],\n    {'flour': ['2', 'cup'], 'sugar ': ['3', 'tbsp']}],\n   [['berry', '2', 'each'], ['berry', '1', 'cup'], ['flour', '3', 'each'], ['grape', '750', 'g']]],\n  ['generated control 1',\n   [[[['flour', '1/2', 'each'], ['eggs', '1/2', 'kg']], [['flour', '2', 'cup']],\n     [['berry', '3', 'cup'], ['peas', '3', 'tbsp']]],\n    {'berry': ['4', 'tsp'], 'egg': ['1/3', 'each']}],\n   [['berry', '35/12', 'cup'], ['egg', '500', 'g'], ['flour', '1/2', 'each'], ['flour', '2', 'cup'],\n    ['pea', '3', 'tbsp']]],\n  ['generated control 2',\n   [[[['grape', '3', 'kg'], ['grape', '3/4', 'kg']],\n     [['sugar ', '1', 'kg'], ['tomatoes', '1/2', 'tbsp'], ['potatoes', '2', 'cup'],\n      ['watercress', '1/3', 'kg']]],\n    {}],\n   [['grape', '15/4', 'kg'], ['potato', '2', 'cup'], ['sugar', '1', 'kg'], ['tomato', '3/2', 'tsp'],\n    ['watercress', '1000/3', 'g']]],\n  ['generated control 3',\n   [[[['grapes', '3', 'each'], ['potatoes', '1', 'tbsp'], ['sugar ', '1/2', 'g']]], {}],\n   [['grape', '3', 'each'], ['potato', '1', 'tbsp'], ['sugar', '1/2', 'g']]]],\n [['watercress keeps ss', [[[['watercress', '100', 'g']]], {}], [['watercress', '100', 'g']]],\n  ['single recipe', [[[['flour', '1', 'cup']]], {}], [['flour', '1', 'cup']]],\n  ['merge plurals', [[[['tomatoes', '2', 'each']], [['Tomato', '1', 'each']]], {}],\n   [['tomato', '3', 'each']]],\n  ['regression: pantry subtraction floor',\n   [[[['Tomato', '1/2', 'tbsp'], ['sugar ', '1', 'each'], ['watercress', '1', 'cup'],\n      ['flour', '1/2', 'each']],\n     [['grape', '4', 'kg']]],\n    {'Tomato': ['4', 'cup'], 'grapes': ['3', 'each']}],\n   [['flour', '1/2', 'each'], ['grape', '4', 'kg'], ['sugar', '1', 'each'], ['watercress', '1', 'cup']]],\n  ['repair check: pantry subtraction floor',\n   [[[['berry', '2', 'g'], ['tomatoes', '1', 'tbsp'], ['peas', '3', 'kg'], ['Tomato', '3', 'tbsp']],\n     [['watercress', '4', 'tsp']], [['eggs', '3/4', 'tsp'], ['flour', '1/2', 'g']]],\n    {'grapes': ['3/4', 'tbsp'], 'watercress': ['4', 'tbsp']}],\n   [['berry', '2', 'g'], ['egg', '3/4', 'tsp'], ['flour', '1/2', 'g'], ['pea', '3', 'kg'],\n    ['tomato', '1/4', 'cup']]],\n  ['generated control 1',\n   [[[['sugar ', '2', 'each'], ['watercress', '3/4', 'tsp'], ['sugar ', '1', 'kg'], ['tomatoes', '2', 'kg']]],\n    {}],\n   [['sugar', '2', 'each'], ['sugar', '1', 'kg'], ['tomato', '2', 'kg'], ['watercress', '3/4', 'tsp']]],\n  ['generated control 2',\n   [[[['tomatoes', '1/2', 'kg'], ['potatoes', '3/4', 'g'], ['sugar ', '3/4', 'g'], ['Tomato', '4', 'tsp']],\n     [['berries', '2', 'tbsp']]],\n    {}],\n   [['berry', '2', 'tbsp'], ['potato', '3/4', 'g'], ['sugar', '3/4', 'g'], ['tomato', '500', 'g'],\n    ['tomato', '4/3', 'tbsp']]],\n  ['generated control 3',\n   [[[['peas', '3', 'kg'], ['potatoes', '3', 'cup']]], {'Tomato': ['1/4', 'tbsp'], 'peas': ['1', 'cup']}],\n   [['pea', '3', 'kg'], ['potato', '3', 'cup']]]],\n [['single recipe', [[[['flour', '1', 'cup']]], {}], [['flour', '1', 'cup']]],\n  ['merge plurals', [[[['tomatoes', '2', 'each']], [['Tomato', '1', 'each']]], {}],\n   [['tomato', '3', 'each']]],\n  ['pantry covers all', [[[['eggs', '2', 'each']]], {'egg': ['6', 'each']}], []],\n  ['regression: pantry subtraction floor',\n   [[[['berries', '3/4', 'tbsp'], ['potatoes', '1/2', 'g']],\n     [['flour', '2', 'g'], ['grapes', '1/3', 'g'], ['grape', '1/3', 'each']],\n     [['sugar ', '2', 'tsp'], ['eggs', '2', 'each'], ['peas', '1', 'cup'], ['watercress', '4', 'tsp']]],\n    {'sugar ': ['3', 'tsp']}],\n   [['berry', '9/4', 'tsp'], ['egg', '2', 'each'], ['flour', '2', 'g'], ['grape', '1/3', 'each'],\n    ['grape', '1/3', 'g'], ['pea', '1', 'cup'], ['potato', '1/2', 'g'], ['watercress', '4/3', 'tbsp']]],\n  ['repair check: pantry subtraction floor',\n   [[[['tomatoes', '2', 'g'], ['grape', '3', 'tsp'], ['egg', '2', 'g']],\n     [['watercress', '1/3', 'g'], ['grapes', '4', 'kg'], ['grape', '2', 'kg'], ['watercress', '1/2', 'tsp']]],\n    {'Tomato': ['4', 'g'], 'eggs': ['1/4', 'each']}],\n   [['egg', '2', 'g'], ['grape', '6', 'kg'], ['grape', '1', 'tbsp'], ['watercress', '1/3', 'g'],\n    ['watercress', '1/2', 'tsp']]],\n  ['generated control 1',\n   [[[['grape', '1/4', 'each'], ['peas', '4', 'g'], ['sugar ', '2', 'tbsp'], ['tomatoes', '1/2', 'each']],\n     [['potatoes', '1/3', 'g'], ['potatoes', '1/2', 'each'], ['Tomato', '1/2', 'tsp'],\n      ['watercress', '3', 'tsp']],\n     [['grapes', '3/4', 'tsp']]],\n    {'berries': ['4', 'tsp'], 'egg': ['2', 'tbsp']}],\n   [['grape', '1/4', 'each'], ['grape', '3/4', 'tsp'], ['pea', '4', 'g'], ['potato', '1/2', 'each'],\n    ['potato', '1/3', 'g'], ['sugar', '2', 'tbsp'], ['tomato', '1/2', 'each'], ['tomato', '1/2', 'tsp'],\n    ['watercress', '1', 'tbsp']]],\n  ['generated control 2',\n   [[[['grapes', '4', 'tbsp'], ['eggs', '1/3', 'tbsp'], ['egg', '3/4', 'kg']], [['sugar ', '3', 'kg']]], {}],\n   [['egg', '750', 'g'], ['egg', '1', 'tsp'], ['grape', '1/4', 'cup'], ['sugar', '3', 'kg']]],\n  ['generated control 3',\n   [[[['peas', '1/4', 'each'], ['sugar ', '4', 'each'], ['peas', '4', 'kg'], ['potatoes', '1/3', 'kg']],\n     [['grape', '1/3', 'cup']]],\n    {'grape': ['3/4', 'tsp']}],\n   [['grape', '61/192', 'cup'], ['pea', '1/4', 'each'], ['pea', '4', 'kg'], ['potato', '1000/3', 'g'],\n    ['sugar', '4', 'each']]]]]\nfor label, args, expected in fixtures[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":"A deterministic toy contract stated in full here; it is a bounded teaching model, not an authoritative reference or standards implementation. 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-recipe_scaling_and_nutrition-shopping-list-pantry-subtraction-floor","generated_at":"2026-09-29T14:52:29.189557+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Meal planners merge ingredient lists across recipes and subtract what is already in the pantry.","root_cause":"Pantry subtraction is not clamped at zero.","sha256":"68e9e3b6e55d10b35a94cbd9085f1df7d43949cd60efd95a27f82e1a118500ce","title":"Shopping list aggregator: pantry subtraction floor · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":43.139,"exit_code":1,"observations":[{"actual":[["flour","1","cup"]],"check":"single recipe","expected":[["flour","1","cup"]],"passed":true},{"actual":[["tomato","3","each"]],"check":"merge plurals","expected":[["tomato","3","each"]],"passed":true},{"actual":[["egg","4","each"]],"check":"pantry covers all","expected":[],"passed":false},{"actual":[["egg","1","kg"],["grape","3/4","tsp"],["pea","7/4","each"]],"check":"regression: pantry subtraction floor","expected":[["egg","1","kg"],["grape","3/4","tsp"]],"passed":false},{"actual":[["egg","1/3","cup"],["flour","1","kg"],["flour","4/3","tbsp"],["grape","1/2","g"],["pea","6","each"],["pea","3/2","tsp"],["potato","1/4","tsp"],["tomato","500","g"],["tomato","5/2","cup"],["watercress","49/64","cup"]],"check":"repair check: pantry subtraction floor","expected":[["egg","1/3","cup"],["flour","1","kg"],["flour","4/3","tbsp"],["grape","1/2","g"],["pea","6","each"],["pea","3/2","tsp"],["potato","1/4","tsp"],["tomato","500","g"],["watercress","49/64","cup"]],"passed":false},{"actual":[["berry","4","kg"],["egg","4001/4000","kg"],["egg","7/6","tbsp"],["grape","1/3","cup"],["sugar","3/4","g"],["watercress","4","g"],["watercress","1/2","tsp"]],"check":"generated control 1","expected":[["berry","4","kg"],["egg","4001/4000","kg"],["egg","7/6","tbsp"],["grape","1/3","cup"],["sugar","3/4","g"],["watercress","4","g"],["watercress","1/2","tsp"]],"passed":true},{"actual":[["berry","3/4","cup"],["potato","8001/4000","kg"],["tomato","4/3","tbsp"]],"check":"generated control 2","expected":[["berry","3/4","cup"],["potato","8001/4000","kg"],["tomato","4/3","tbsp"]],"passed":true},{"actual":[["flour","1","tsp"],["pea","1/3","g"]],"check":"generated control 3","expected":[["flour","1","tsp"],["pea","1/3","g"]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"single recipe\", \"actual\": [[\"flour\", \"1\", \"cup\"]], \"expected\": [[\"flour\", \"1\", \"cup\"]], \"passed\": true}, {\"check\": \"merge plurals\", \"actual\": [[\"tomato\", \"3\", \"each\"]], \"expected\": [[\"tomato\", \"3\", \"each\"]], \"passed\": true}, {\"check\": \"pantry covers all\", \"actual\": [[\"egg\", \"4\", \"each\"]], \"expected\": [], \"passed\": false}, {\"check\": \"regression: pantry subtraction floor\", \"actual\": [[\"egg\", \"1\", \"kg\"], [\"grape\", \"3/4\", \"tsp\"], [\"pea\", \"7/4\", \"each\"]], \"expected\": [[\"egg\", \"1\", \"kg\"], [\"grape\", \"3/4\", \"tsp\"]], \"passed\": false}, {\"check\": \"repair check: pantry subtraction floor\", \"actual\": [[\"egg\", \"1/3\", \"cup\"], [\"flour\", \"1\", \"kg\"], [\"flour\", \"4/3\", \"tbsp\"], [\"grape\", \"1/2\", \"g\"], [\"pea\", \"6\", \"each\"], [\"pea\", \"3/2\", \"tsp\"], [\"potato\", \"1/4\", \"tsp\"], [\"tomato\", \"500\", \"g\"], [\"tomato\", \"5/2\", \"cup\"], [\"watercress\", \"49/64\", \"cup\"]], \"expected\": [[\"egg\", \"1/3\", \"cup\"], [\"flour\", \"1\", \"kg\"], [\"flour\", \"4/3\", \"tbsp\"], [\"grape\", \"1/2\", \"g\"], [\"pea\", \"6\", \"each\"], [\"pea\", \"3/2\", \"tsp\"], [\"potato\", \"1/4\", \"tsp\"], [\"tomato\", \"500\", \"g\"], [\"watercress\", \"49/64\", \"cup\"]], \"passed\": false}, {\"check\": \"generated control 1\", \"actual\": [[\"berry\", \"4\", \"kg\"], [\"egg\", \"4001/4000\", \"kg\"], [\"egg\", \"7/6\", \"tbsp\"], [\"grape\", \"1/3\", \"cup\"], [\"sugar\", \"3/4\", \"g\"], [\"watercress\", \"4\", \"g\"], [\"watercress\", \"1/2\", \"tsp\"]], \"expected\": [[\"berry\", \"4\", \"kg\"], [\"egg\", \"4001/4000\", \"kg\"], [\"egg\", \"7/6\", \"tbsp\"], [\"grape\", \"1/3\", \"cup\"], [\"sugar\", \"3/4\", \"g\"], [\"watercress\", \"4\", \"g\"], [\"watercress\", \"1/2\", \"tsp\"]], \"passed\": true}, {\"check\": \"generated control 2\", \"actual\": [[\"berry\", \"3/4\", \"cup\"], [\"potato\", \"8001/4000\", \"kg\"], [\"tomato\", \"4/3\", \"tbsp\"]], \"expected\": [[\"berry\", \"3/4\", \"cup\"], [\"potato\", \"8001/4000\", \"kg\"], [\"tomato\", \"4/3\", \"tbsp\"]], \"passed\": true}, {\"check\": \"generated control 3\", \"actual\": [[\"flour\", \"1\", \"tsp\"], [\"pea\", \"1/3\", \"g\"]], \"expected\": [[\"flour\", \"1\", \"tsp\"], [\"pea\", \"1/3\", \"g\"]], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":45.669,"exit_code":1,"observations":[{"actual":[["flour","1","cup"]],"check":"single recipe","expected":[["flour","1","cup"]],"passed":true},{"actual":[["tomato","3","each"]],"check":"merge plurals","expected":[["tomato","3","each"]],"passed":true},{"actual":[["egg","-4","each"]],"check":"pantry covers all","expected":[],"passed":false},{"actual":[["egg","1","kg"],["grape","3/4","tsp"],["pea","-7/4","each"]],"check":"regression: pantry subtraction floor","expected":[["egg","1","kg"],["grape","3/4","tsp"]],"passed":false},{"actual":[["egg","1/3","cup"],["flour","1","kg"],["flour","4/3","tbsp"],["grape","1/2","g"],["pea","6","each"],["pea","3/2","tsp"],["potato","1/4","tsp"],["tomato","500","g"],["tomato","-120","tsp"],["watercress","49/64","cup"]],"check":"repair check: pantry subtraction floor","expected":[["egg","1/3","cup"],["flour","1","kg"],["flour","4/3","tbsp"],["grape","1/2","g"],["pea","6","each"],["pea","3/2","tsp"],["potato","1/4","tsp"],["tomato","500","g"],["watercress","49/64","cup"]],"passed":false},{"actual":[["berry","4","kg"],["egg","4001/4000","kg"],["egg","7/6","tbsp"],["grape","1/3","cup"],["sugar","3/4","g"],["watercress","4","g"],["watercress","1/2","tsp"]],"check":"generated control 1","expected":[["berry","4","kg"],["egg","4001/4000","kg"],["egg","7/6","tbsp"],["grape","1/3","cup"],["sugar","3/4","g"],["watercress","4","g"],["watercress","1/2","tsp"]],"passed":true},{"actual":[["berry","3/4","cup"],["potato","8001/4000","kg"],["tomato","4/3","tbsp"]],"check":"generated control 2","expected":[["berry","3/4","cup"],["potato","8001/4000","kg"],["tomato","4/3","tbsp"]],"passed":true},{"actual":[["flour","1","tsp"],["pea","1/3","g"]],"check":"generated control 3","expected":[["flour","1","tsp"],["pea","1/3","g"]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"single recipe\", \"actual\": [[\"flour\", \"1\", \"cup\"]], \"expected\": [[\"flour\", \"1\", \"cup\"]], \"passed\": true}, {\"check\": \"merge plurals\", \"actual\": [[\"tomato\", \"3\", \"each\"]], \"expected\": [[\"tomato\", \"3\", \"each\"]], \"passed\": true}, {\"check\": \"pantry covers all\", \"actual\": [[\"egg\", \"-4\", \"each\"]], \"expected\": [], \"passed\": false}, {\"check\": \"regression: pantry subtraction floor\", \"actual\": [[\"egg\", \"1\", \"kg\"], [\"grape\", \"3/4\", \"tsp\"], [\"pea\", \"-7/4\", \"each\"]], \"expected\": [[\"egg\", \"1\", \"kg\"], [\"grape\", \"3/4\", \"tsp\"]], \"passed\": false}, {\"check\": \"repair check: pantry subtraction floor\", \"actual\": [[\"egg\", \"1/3\", \"cup\"], [\"flour\", \"1\", \"kg\"], [\"flour\", \"4/3\", \"tbsp\"], [\"grape\", \"1/2\", \"g\"], [\"pea\", \"6\", \"each\"], [\"pea\", \"3/2\", \"tsp\"], [\"potato\", \"1/4\", \"tsp\"], [\"tomato\", \"500\", \"g\"], [\"tomato\", \"-120\", \"tsp\"], [\"watercress\", \"49/64\", \"cup\"]], \"expected\": [[\"egg\", \"1/3\", \"cup\"], [\"flour\", \"1\", \"kg\"], [\"flour\", \"4/3\", \"tbsp\"], [\"grape\", \"1/2\", \"g\"], [\"pea\", \"6\", \"each\"], [\"pea\", \"3/2\", \"tsp\"], [\"potato\", \"1/4\", \"tsp\"], [\"tomato\", \"500\", \"g\"], [\"watercress\", \"49/64\", \"cup\"]], \"passed\": false}, {\"check\": \"generated control 1\", \"actual\": [[\"berry\", \"4\", \"kg\"], [\"egg\", \"4001/4000\", \"kg\"], [\"egg\", \"7/6\", \"tbsp\"], [\"grape\", \"1/3\", \"cup\"], [\"sugar\", \"3/4\", \"g\"], [\"watercress\", \"4\", \"g\"], [\"watercress\", \"1/2\", \"tsp\"]], \"expected\": [[\"berry\", \"4\", \"kg\"], [\"egg\", \"4001/4000\", \"kg\"], [\"egg\", \"7/6\", \"tbsp\"], [\"grape\", \"1/3\", \"cup\"], [\"sugar\", \"3/4\", \"g\"], [\"watercress\", \"4\", \"g\"], [\"watercress\", \"1/2\", \"tsp\"]], \"passed\": true}, {\"check\": \"generated control 2\", \"actual\": [[\"berry\", \"3/4\", \"cup\"], [\"potato\", \"8001/4000\", \"kg\"], [\"tomato\", \"4/3\", \"tbsp\"]], \"expected\": [[\"berry\", \"3/4\", \"cup\"], [\"potato\", \"8001/4000\", \"kg\"], [\"tomato\", \"4/3\", \"tbsp\"]], \"passed\": true}, {\"check\": \"generated control 3\", \"actual\": [[\"flour\", \"1\", \"tsp\"], [\"pea\", \"1/3\", \"g\"]], \"expected\": [[\"flour\", \"1\", \"tsp\"], [\"pea\", \"1/3\", \"g\"]], \"passed\": true}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}