from common import register D = 'multi_step_word' def add(n, c, t, s, e, **kw): register(D, n, c, t, s, e, **kw) add('inventory_reorders', [['A shop starts with {a} items, receives {b} boxes of {c} items, then sells {d} items.', 'Initial stock is {a}; a delivery adds {b} boxes with {c} items each, and sales remove {d} items.', 'The shop has {a} items before receiving {b} cartons of {c}; afterward, {d} items are sold.'], ['It packs all remaining items into full bundles of {k}, setting any leftovers aside.', 'The remaining stock is bundled in groups of {k}, and incomplete bundles are not counted.', 'Only complete bundles of size {k} are made from the stock that remains.']], ['How many full bundles can be made?', 'Find the number of complete bundles.', 'Determine the full-bundle count.'], lambda r: dict(a=r.randint(80, 300), b=r.randint(5, 20), c=r.randint(8, 30), d=r.randint(10, 70), k=r.randint(4, 15)), [('delivery', 'b*c'), ('remaining', 'a+delivery-d'), ('answer', 'floor(remaining/k)')], level='easy', depth=3) add('tank_schedule', [['A tank starts with {v} liters; a pump adds {p} liters per minute while a drain removes {d} liters per minute.', 'Initially the tank holds {v} liters, with constant inflow {p} liters/min and constant outflow {d} liters/min.', 'The tank initially contains {v} liters; its pump rate is {p} liters per minute and drain rate is {d} liters per minute.'], ['Both run for {t} minutes, then only the drain runs for {u} more minutes; the tank has sufficient capacity.', 'Run both for {t} minutes; turn off the pump and drain for another {u} minutes, with no overflow.', 'After {t} minutes of simultaneous inflow and outflow, stop the inflow and continue draining for {u} minutes, without overflow.']], ['How many liters remain?', 'Find the final water volume in liters.', 'Determine the remaining volume.'], lambda r: dict(v=r.randint(150, 500), p=r.randint(8, 20), d=r.randint(2, 6), t=r.randint(5, 20), u=r.randint(3, 15)), [('after_joint', 'v+(p-d)*t'), ('answer', 'after_joint-d*u')], level='medium', depth=3) add('savings_deposit_interest', [['An account starts with {v} monetary units and earns {p}% interest over the first year.', 'The initial balance is {v}, with a first-year interest rate of {p}%.', 'Deposit an initial {v}; the account credits {p}% interest at the end of year one.'], ['Immediately after that interest, deposit {d}; the entire balance then earns {q}% in year two, with no fees or rounding.', 'Add {d} after first-year interest, then apply {q}% second-year interest to everything; no rounding or fees apply.', 'Following the first interest credit, add {d} and earn {q}% in the second year, retaining exact amounts without fees.']], ['What is the balance after year two?', 'Find the final account balance.', 'Determine the balance after both interest credits.'], lambda r: dict(v=r.randint(200, 2500), p=r.randint(2, 12), d=r.randint(100, 700), q=r.randint(2, 12)), [('first_year', 'v*(100+p)/100'), ('after_deposit', 'first_year+d'), ('answer', 'after_deposit*(100+q)/100')], level='medium', depth=3) def production(r): b = r.randint(10, 40) s = r.randint(10, 25) d = r.randint(2, 7) return dict(b=b, s=s, d=d, k=r.randint(5, 20)) add('production_rejects', [['A factory makes {b} batches of {s} units; exactly {d} units in each batch fail inspection.', 'Production has {b} batches, each with {s} units, of which {d} per batch are rejected.', 'Each of {b} production batches contains {s} units and loses {d} units to inspection failures.'], ['All accepted units are packed into cartons of {k}; any partial carton remains unshipped.', 'Only full cartons containing {k} accepted units are shipped.', 'Pack the good units into size-{k} cartons and ship only complete cartons.']], ['How many accepted units remain unshipped?', 'Find the number of good units left after filling all full cartons.', 'Determine the leftover accepted-unit count.'], production, [('accepted', 'b*(s-d)'), ('full_cartons', 'floor(accepted/k)'), ('answer', 'accepted-full_cartons*k')], level='easy', depth=3) add('budget_coupon', [['A shopper has budget {v}; a purchase has a fixed delivery charge {f} and each identical item costs {p}.', 'Each item costs {p}, delivery costs {f} per order, and the total budget is {v}.', 'The available money is {v}, with item price {p} and one delivery fee of {f}.'], ['A coupon subtracts {c} from the merchandise total, and requires buying at least {m} items; delivery is not discounted.', 'Buying at least {m} items activates a {c}-unit merchandise discount; the delivery fee is unchanged.', 'The order must contain at least {m} items to use a coupon worth {c}, applied only to merchandise.']], ['What is the maximum number of items affordable when using the coupon?', 'Find the largest affordable item count with the coupon applied.', 'Determine how many items can be bought at most using this offer.'], lambda r: dict(v=r.randint(150, 500), f=r.randint(5, 20), p=r.randint(10, 25), c=r.randint(5, 18), m=r.randint(3, 5)), [('merchandise_budget', 'v-f+c'), ('answer', 'floor(merchandise_budget/p)')], level='hard', depth=3, concepts=3) add('reservoir_fractional_loss', [['A reservoir starts with {v} liters; {p}% of the current water evaporates before {a} liters are added.', 'Initially there are {v} liters; evaporation removes {p} percent, and a refill then adds {a} liters.', 'The initial {v} liters lose {p}% to evaporation; afterward, add {a} liters.'], ['Then {q}% of the new contents are drained, with no further losses.', 'A subsequent drain removes {q} percent of the refilled volume.', 'After refilling, withdraw {q}% of the water and make no other changes.']], ['How many liters remain?', 'Find the final volume in liters.', 'Determine the remaining water quantity.'], lambda r: dict(v=r.randint(200, 1500), p=r.randint(5, 30), a=r.randint(30, 200), q=r.randint(5, 30)), [('post_evaporation', 'v*(100-p)/100'), ('refilled', 'post_evaporation+a'), ('answer', 'refilled*(100-q)/100')], level='hard', depth=3, concepts=3)