templates 40 files
Browse files- sft_v1/tmpl/tp_tp2c_1791582479_00000.jsonl +0 -0
- sft_v1/tmpl/tp_tp2c_1791582479_00001.jsonl +0 -0
- sft_v1/tmpl/tp_tp2c_1791582479_00002.jsonl +0 -0
- sft_v1/tmpl/tp_tp2c_1791582479_00003.jsonl +0 -0
- sft_v1/tmpl/tp_tp2c_1791582479_00004.jsonl +0 -0
- sft_v1/tmpl/tp_tp2c_1791582479_00005.jsonl +0 -0
- sft_v1/tmpl/tp_tp2c_1791582479_00006.jsonl +0 -0
- sft_v1/tmpl/tp_tp2c_1791582479_00007.jsonl +0 -0
- sft_v1/tmpl/tp_tp2c_1791582479_00008.jsonl +0 -0
- sft_v1/tmpl/tp_tp2c_1791582479_00009.jsonl +0 -0
- sft_v1/tmpl/tp_tp2c_1791582479_00010.jsonl +0 -0
- sft_v1/tmpl/tp_tp2c_1791582479_00011.jsonl +0 -0
- sft_v1/tmpl/tp_tp2c_1791582479_00012.jsonl +0 -0
- sft_v1/tmpl/tp_tp2c_1791582479_00013.jsonl +0 -0
- sft_v1/tmpl/tp_tp2c_1791582479_00014.jsonl +0 -0
- sft_v1/tmpl/tp_tp2c_1791582479_00015.jsonl +0 -0
- sft_v1/tmpl/tp_tp2c_1791582479_00016.jsonl +0 -0
- sft_v1/tmpl/tp_tp2c_1791582479_00018.jsonl +0 -0
- sft_v1/tmpl/tp_tp2c_1791582479_00019.jsonl +0 -0
- tmpl_code/tc_tp2c_1791582479_00000.jsonl +0 -0
- tmpl_code/tc_tp2c_1791582479_00001.jsonl +0 -0
- tmpl_code/tc_tp2c_1791582479_00002.jsonl +0 -0
- tmpl_code/tc_tp2c_1791582479_00003.jsonl +0 -0
- tmpl_code/tc_tp2c_1791582479_00004.jsonl +0 -0
- tmpl_code/tc_tp2c_1791582479_00005.jsonl +0 -0
- tmpl_code/tc_tp2c_1791582479_00006.jsonl +25 -0
- tmpl_code/tc_tp2c_1791582479_00007.jsonl +0 -0
- tmpl_code/tc_tp2c_1791582479_00008.jsonl +0 -0
- tmpl_code/tc_tp2c_1791582479_00009.jsonl +0 -0
- tmpl_code/tc_tp2c_1791582479_00010.jsonl +0 -0
- tmpl_code/tc_tp2c_1791582479_00011.jsonl +0 -0
- tmpl_code/tc_tp2c_1791582479_00012.jsonl +0 -0
- tmpl_code/tc_tp2c_1791582479_00013.jsonl +0 -0
- tmpl_code/tc_tp2c_1791582479_00014.jsonl +0 -0
- tmpl_code/tc_tp2c_1791582479_00015.jsonl +0 -0
- tmpl_code/tc_tp2c_1791582479_00016.jsonl +0 -0
- tmpl_code/tc_tp2c_1791582479_00017.jsonl +0 -0
- tmpl_code/tc_tp2c_1791582479_00018.jsonl +0 -0
- tmpl_code/tc_tp2c_1791582479_00019.jsonl +0 -0
sft_v1/tmpl/tp_tp2c_1791582479_00000.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sft_v1/tmpl/tp_tp2c_1791582479_00001.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sft_v1/tmpl/tp_tp2c_1791582479_00002.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sft_v1/tmpl/tp_tp2c_1791582479_00003.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sft_v1/tmpl/tp_tp2c_1791582479_00004.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sft_v1/tmpl/tp_tp2c_1791582479_00005.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sft_v1/tmpl/tp_tp2c_1791582479_00006.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sft_v1/tmpl/tp_tp2c_1791582479_00007.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sft_v1/tmpl/tp_tp2c_1791582479_00008.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sft_v1/tmpl/tp_tp2c_1791582479_00009.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sft_v1/tmpl/tp_tp2c_1791582479_00010.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sft_v1/tmpl/tp_tp2c_1791582479_00011.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sft_v1/tmpl/tp_tp2c_1791582479_00012.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sft_v1/tmpl/tp_tp2c_1791582479_00013.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sft_v1/tmpl/tp_tp2c_1791582479_00014.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sft_v1/tmpl/tp_tp2c_1791582479_00015.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sft_v1/tmpl/tp_tp2c_1791582479_00016.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sft_v1/tmpl/tp_tp2c_1791582479_00018.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sft_v1/tmpl/tp_tp2c_1791582479_00019.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tmpl_code/tc_tp2c_1791582479_00000.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tmpl_code/tc_tp2c_1791582479_00001.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tmpl_code/tc_tp2c_1791582479_00002.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tmpl_code/tc_tp2c_1791582479_00003.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tmpl_code/tc_tp2c_1791582479_00004.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tmpl_code/tc_tp2c_1791582479_00005.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tmpl_code/tc_tp2c_1791582479_00006.jsonl
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"tid": "72f165351b", "cat": "wordproblem", "code": "import random\n\ndef make(rng, original=False):\n if original:\n question = (\"A clinical trial tracks the viral load reduction in patients taking a daily prophylactic medication. \"\n \"The drug has a half-life of 12 hours, and the initial plasma concentration is 200 mg/L. \"\n \"If the patient misses a dose for exactly 36 hours, what is the remaining concentration in mg/L \"\n \"after that period, assuming no new doses are taken and decay follows first-order kinetics?\")\n lines = [\n \"The decay follows first-order kinetics with a half-life of 12 hours.\",\n \"The elapsed time is 36 hours.\",\n \"The number of half-lives elapsed is 36 / 12 = 3.\",\n \"The remaining concentration is calculated as C = C0 * (1/2)^n.\",\n \"Substituting the values gives C = 200 * (1/2)^3.\",\n \"(1/2)^3 = 1/8.\",\n \"C = 200 * (1/8).\",\n \"C = 25.\",\n ]\n answer = \"25 mg/L\"\n return question, lines, answer\n\n # Choose parameters that yield an integer answer\n half_lives = rng.randint(2, 5)\n half_life = rng.randint(6, 24)\n C0 = rng.randint(2, 12) * (2 ** half_lives) # ensures integer result\n elapsed = half_life * half_lives\n\n question = (\n f\"A pharmacokinetics study measures the decay of a drug in plasma. \"\n f\"The drug has a half-life of {half_life} hours, and the initial concentration is {C0} mg/L. \"\n f\"If no additional doses are administered for {elapsed} hours, what is the remaining concentration in mg/L, \"\n f\"assuming first-order decay kinetics?\"\n )\n\n n = elapsed // half_life\n factor = 1 / (2 ** n)\n C = C0 * factor\n\n lines = [\n f\"The decay follows first-order kinetics with a half-life of {half_life} hours.\",\n f\"The elapsed time is {elapsed} hours.\",\n f\"The number of half-lives elapsed is {elapsed} / {half_life} = {n}.\",\n f\"The remaining concentration is calculated as C = C0 * (1/2)^n.\",\n f\"Substituting the values gives C = {C0} * (1/2)^{n}.\",\n f\"(1/2)^{n} = {factor}.\",\n f\"C = {C0} * {factor}.\",\n f\"C = {int(C)}.\",\n ]\n answer = f\"{int(C)} mg/L\"\n return question, lines, answer\n"}
|
| 2 |
+
{"tid": "837ce007ad", "cat": "logic", "code": "import random\nimport itertools\n\ndef make(rng, original=False):\n if original:\n question = (\"During the volatility of the 1973\u20131974 bear market, four traders\u2014A, B, C, and D\u2014held \"\n \"positions in oil, grain, tech, and bonds, respectively. We know that: A did not hold bonds. \"\n \"B held oil. C did not hold grain or tech. D held neither grain nor bonds. \"\n \"Which trader held the tech portfolio?\")\n lines = [\n \"B held oil.\",\n \"C did not hold grain or tech, and oil was taken by B, so C held bonds.\",\n \"D did not hold grain or bonds, and oil was taken by B, so D held tech.\",\n \"A held grain.\",\n ]\n return question, lines, \"D\"\n\n # Generate a new assignment puzzle of the same structure:\n # 4 traders, 4 assets, clues: one direct assignment, two \"not X or Y\" clues, one \"not Z\" clue.\n # We need exactly one valid permutation.\n\n traders = [\"A\", \"B\", \"C\", \"D\"]\n assets = [\"oil\", \"grain\", \"tech\", \"bonds\"]\n\n # Choose a random permutation as the true solution\n true_assign = assets[:]\n rng.shuffle(true_assign)\n sol = dict(zip(traders, true_assign))\n\n # Clue structure:\n # - One trader is directly assigned an asset (clue: \"X held Y\")\n # - One trader has two exclusions (clue: \"X did not hold P or Q\")\n # - One trader has two exclusions (clue: \"X did not hold P or Q\")\n # - One trader has one exclusion (clue: \"X did not hold P\")\n # The excluded assets must be consistent with the true assignment.\n\n # Choose which trader gets the direct clue\n direct_trader = rng.choice(traders)\n direct_asset = sol[direct_trader]\n\n # Choose two traders for the \"not P or Q\" clues (must not be the direct trader)\n remaining = [t for t in traders if t != direct_trader]\n two_excl_traders = rng.sample(remaining, 2)\n\n # The last trader gets one exclusion\n one_excl_trader = [t for t in remaining if t not in two_excl_traders][0]\n\n # For each \"not P or Q\" trader, pick two assets that are NOT their true asset\n def pick_exclusions(trader, count):\n true_a = sol[trader]\n others = [a for a in assets if a != true_a]\n return rng.sample(others, count)\n\n excl1 = pick_exclusions(two_excl_traders[0], 2)\n excl2 = pick_exclusions(two_excl_traders[1], 2)\n excl3 = pick_exclusions(one_excl_trader, 1)\n\n # Build the clue list\n clues = []\n # Randomize clue order for variety\n clue_items = [\n (direct_trader, \"direct\", direct_asset),\n (two_excl_traders[0], \"two\", excl1),\n (two_excl_traders[1], \"two\", excl2),\n (one_excl_trader, \"one\", excl3),\n ]\n rng.shuffle(clue_items)\n\n # Verify uniqueness via brute force\n valid_solutions = []\n for perm in itertools.permutations(assets):\n assign = dict(zip(traders, perm))\n ok = True\n for trader, ctype, data in clue_items:\n if ctype == \"direct\":\n if assign[trader] != data:\n ok = False\n break\n elif ctype == \"two\":\n if assign[trader] in data:\n ok = False\n break\n elif ctype == \"one\":\n if assign[trader] in data:\n ok = False\n break\n if ok:\n valid_solutions.append(assign)\n\n if len(valid_solutions) != 1:\n return None\n\n # Build question\n clue_strs = []\n for trader, ctype, data in clue_items:\n if ctype == \"direct\":\n clue_strs.append(f\"{trader} held {data}.\")\n elif ctype == \"two\":\n clue_strs.append(f\"{trader} did not hold {data[0]} or {data[1]}.\")\n elif ctype == \"one\":\n clue_strs.append(f\"{trader} did not hold {data[0]}.\")\n\n # Vary the question wording slightly\n intro_variants = [\n \"In a volatile market period, four traders\u2014A, B, C, and D\u2014held positions in oil, grain, tech, and bonds, respectively. We know that: \",\n \"During a turbulent trading period, four traders\u2014A, B, C, and D\u2014each held one of the following portfolios: oil, grain, tech, and bonds. The following is known: \",\n \"Four traders\u2014A, B, C, and D\u2014were managing portfolios in oil, grain, tech, and bonds. Given the following clues: \",\n ]\n intro = rng.choice(intro_variants)\n question = intro + \" \".join(clue_strs) + \" Which trader held the tech portfolio?\"\n\n # Build solution lines\n sol_lines = []\n # Line 1: direct assignment\n sol_lines.append(f\"{direct_trader} held {direct_asset}.\")\n\n # For each \"two\" exclusion, deduce the remaining asset\n used = {direct_asset}\n for trader, ctype, data in clue_items:\n if ctype == \"two\":\n # The two excluded assets are in data, so the trader holds the one not in data and not used\n # Actually, the trader's asset is the one not in data and not already assigned\n # Since data has 2 exclusions, the trader's asset is the one from assets not in data and not used\n # But we need to compute it properly\n pass\n\n # Better approach: reconstruct the deduction step by step\n # Start with the direct clue\n assigned = {direct_trader: direct_asset}\n remaining_traders = [t for t in traders if t != direct_trader]\n remaining_assets = [a for a in assets if a != direct_asset]\n\n # Process the \"two\" exclusion clues in order\n for trader, ctype, data in clue_items:\n if ctype == \"two\" and trader in remaining_traders:\n # The trader's asset is the one in remaining_assets that is not in data\n # Since data has 2 assets and remaining_assets has 3, one of remaining_assets is not in data\n possible = [a for a in remaining_assets if a not in data]\n # Should be exactly 1\n if len(possible) == 1:\n assigned[trader] = possible[0]\n sol_lines.append(f\"{trader} did not hold {data[0]} or {data[1]}, and {direct_asset} was taken by {direct_trader}, so {trader} held {possible[0]}.\")\n remaining_traders.remove(trader)\n remaining_assets.remove(possible[0])\n\n # Process the \"one\" exclusion clue\n for trader, ctype, data in clue_items:\n if ctype == \"one\" and trader in remaining_traders:\n possible = [a for a in remaining_assets if a not in data]\n if len(possible) == 1:\n assigned[trader] = possible[0]\n sol_lines.append(f\"{trader} did not hold {data[0]}, and the remaining assets were {', '.join(remaining_assets)}, so {trader} held {possible[0]}.\")\n remaining_traders.remove(trader)\n remaining_assets.remove(possible[0])\n\n # The last trader gets the last asset\n if remaining_traders:\n trader = remaining_traders[0]\n asset = remaining_assets[0]\n assigned[trader] = asset\n sol_lines.append(f\"{trader} held {asset}.\")\n\n # Verify our deduction matches the true solution\n if assigned != sol:\n return None\n\n # The answer is the trader who held tech\n answer_trader = [t for t, a in assigned.items() if a == \"tech\"][0]\n\n return question, sol_lines, answer_trader\n"}
|
| 3 |
+
{"tid": "a93ed91908", "cat": "finance", "code": "import random\n\ndef make(rng, original=False):\n if original:\n question = (\"A corporate bond issued by a retail firm similar to Michael Dumanis\u2019s former employer \"\n \"has a face value of $1,000, a coupon rate of 6% payable annually, and matures in 10 years. \"\n \"If the required yield to maturity is 8%, what is the current market price of the bond, \"\n \"rounded to the nearest cent?\")\n lines = [\n \"Annual coupon = 0.06 \u00d7 1000 = 60\",\n \"Discount factor = (1.08)^(-10) = 0.463193488\",\n \"Annuity factor = (1 \u2212 0.463193488) / 0.08 = 6.7100814\",\n \"Present value of coupons = 60 \u00d7 6.7100814 = 402.604884\",\n \"Present value of face value = 1000 \u00d7 0.463193488 = 463.193488\",\n \"Bond price = 402.604884 + 463.193488 = 865.798372\",\n \"Rounded to nearest cent = 865.80\"\n ]\n return question, lines, \"$865.80\"\n\n face = rng.choice([1000, 1000, 1000, 1000])\n years = rng.randint(5, 15)\n coupon_rate = rng.choice([0.04, 0.05, 0.06, 0.07, 0.08])\n ytm = rng.choice([0.05, 0.06, 0.07, 0.08, 0.09, 0.10])\n if ytm == coupon_rate:\n return None\n\n coupon = coupon_rate * face\n df = (1 + ytm) ** (-years)\n annuity = (1 - df) / ytm\n pv_coupons = coupon * annuity\n pv_face = face * df\n price = pv_coupons + pv_face\n price_rounded = round(price, 2)\n\n companies = [\"Apex\", \"Blue Harbor\", \"Crestline\", \"Deltacore\", \"Everly\", \"Fenwick\", \"Gallant\", \"Hartwell\"]\n industry = [\"retail\", \"logistics\", \"healthcare\", \"industrial\", \"consumer\", \"technology\"]\n company = rng.choice(companies)\n ind = rng.choice(industry)\n\n question = (f\"A corporate bond issued by a {ind} firm similar to {company} has a face value of ${face}, \"\n f\"a coupon rate of {coupon_rate*100:.0f}% payable annually, and matures in {years} years. \"\n f\"If the required yield to maturity is {ytm*100:.0f}%, what is the current market price of the bond, \"\n f\"rounded to the nearest cent?\")\n\n lines = [\n f\"Annual coupon = {coupon_rate} \u00d7 {face} = {coupon}\",\n f\"Discount factor = ({1+ytm:.2f})^(-{years}) = {df:.7f}\",\n f\"Annuity factor = (1 \u2212 {df:.7f}) / {ytm} = {annuity:.7f}\",\n f\"Present value of coupons = {coupon} \u00d7 {annuity:.7f} = {pv_coupons:.6f}\",\n f\"Present value of face value = {face} \u00d7 {df:.7f} = {pv_face:.6f}\",\n f\"Bond price = {pv_coupons:.6f} + {pv_face:.6f} = {price:.6f}\",\n f\"Rounded to nearest cent = {price_rounded:.2f}\"\n ]\n return question, lines, f\"${price_rounded:.2f}\"\n"}
|
| 4 |
+
{"tid": "8428c450c5", "cat": "planning", "code": "import random\n\ndef make(rng, original=False):\n if original:\n question = (\"In a job-shop scheduling problem, two machines (M1 and M2) process two jobs (J1 and J2). \"\n \"Job J1 requires 10 minutes on M1 followed by 5 minutes on M2. \"\n \"Job J2 requires 4 minutes on M2 followed by 8 minutes on M1. \"\n \"The initial state is that both machines are idle. \"\n \"Using the shortest processing time first rule for each machine as they become available, \"\n \"what is the total makespan (completion time) when both jobs are finished?\")\n lines = [\n \"At time 0, M1 starts J1 (10 min) and M2 starts J2 (4 min).\",\n \"M2 completes J2 at time 4 and idles until time 10.\",\n \"M1 completes J1 at time 10.\",\n \"At time 10, M1 starts J2 (8 min) and M2 starts J1 (5 min).\",\n \"M2 completes J1 at time 15.\",\n \"M1 completes J2 at time 18.\",\n \"The total makespan is the maximum completion time, which is 18.\"\n ]\n return question, lines, \"18\"\n\n # Generate new problem\n # Job 1: M1 then M2\n # Job 2: M2 then M1\n # We need to ensure the problem is valid and non-trivial.\n # To keep the same \"kind of reasoning\" (SPF scheduling on 2 machines, 2 jobs with crossing paths),\n # we pick random processing times.\n \n # Try a few times to get a non-trivial case where the makespan isn't just the sum of one job's times\n # or where the idling is significant.\n for _ in range(20):\n p1_m1 = rng.randint(2, 15)\n p1_m2 = rng.randint(2, 15)\n p2_m2 = rng.randint(2, 15)\n p2_m1 = rng.randint(2, 15)\n \n # Simulate to check validity and compute answer\n # State: (time_m1, time_m2)\n # Jobs: J1 (M1->M2), J2 (M2->M1)\n \n # We can simulate this directly.\n # Time 0:\n # M1 is free, M2 is free.\n # J1 needs M1. J2 needs M2.\n # Both start at 0.\n \n t_m1 = p1_m1\n t_m2 = p2_m2\n \n # Completion times of first operations\n c1_m1 = t_m1\n c2_m2 = t_m2\n \n # Now, the second operations can start when both the machine is free and the previous operation is done.\n # J1's second op (on M2) can start at max(t_m2, c1_m1).\n # J2's second op (on M1) can start at max(t_m1, c2_m2).\n \n # Wait, the problem states \"shortest processing time first rule for each machine as they become available\".\n # This implies that when a machine becomes available, it picks the job that has been waiting longest? \n # No, \"shortest processing time first\" usually means among the *available* jobs, pick the one with shortest processing time.\n # However, in a 2-job, 2-machine job shop with fixed routing, the sequence is fixed by dependencies.\n # J1: M1 -> M2\n # J2: M2 -> M1\n \n # Let's re-read the verified solution logic.\n # \"At time 0, M1 starts J1 (10 min) and M2 starts J2 (4 min).\" -> This is forced by routing.\n # \"M2 completes J2 at time 4 and idles until time 10.\" -> M2 is idle from 4 to 10.\n # \"At time 10, M1 starts J2 (8 min) and M2 starts J1 (5 min).\"\n # Why did M2 start J1 at 10? Because J1 finished M1 at 10. J2 finished M2 at 4.\n # So at time 10, M2 is free (has been since 4) and J1 is ready.\n # M1 is free at 10 and J2 is ready (finished M2 at 4).\n # So both start at 10.\n \n # Is there any ambiguity?\n # What if p1_m1 < p2_m2?\n # Example: J1 M1=2, J2 M2=10.\n # t=0: M1 starts J1, M2 starts J2.\n # t=2: M1 finishes J1. M1 is idle. J2 is still on M2.\n # t=10: M2 finishes J2. M2 is idle. J1 is ready for M2. J2 is ready for M1.\n # At t=10, M1 is free, M2 is free.\n # J1 needs M2. J2 needs M1.\n # So M1 starts J2, M2 starts J1.\n # This seems deterministic regardless of \"SPF\" because there's only one job available for each machine at any given time where the machine is free and a job is ready.\n # The \"SPF\" rule might be a distractor or applies if there were more jobs. With 2 jobs and this specific routing (crossing), the schedule is forced by dependencies.\n \n # Let's calculate the makespan for the generated numbers.\n # c1_m1 = p1_m1\n # c2_m2 = p2_m2\n \n # Start time for J1 on M2: max(p2_m2, p1_m1)\n # Start time for J2 on M1: max(p1_m1, p2_m2)\n \n # Wait, if p1_m1 == p2_m2, both start at that time.\n # If p1_m1 > p2_m2:\n # J1 on M2 starts at p1_m1.\n # J2 on M1 starts at p1_m1.\n # If p2_m2 > p1_m1:\n # J1 on M2 starts at p2_m2.\n # J2 on M1 starts at p2_m2.\n \n # So start_time_second_ops = max(p1_m1, p2_m2)\n \n # Completion time for J1: start_time_second_ops + p1_m2\n # Completion time for J2: start_time_second_ops + p2_m1\n \n # Makespan = max(Completion J1, Completion J2)\n \n c1 = max(p1_m1, p2_m2) + p1_m2\n c2 = max(p1_m1, p2_m2) + p2_m1\n makespan = max(c1, c2)\n \n # Check for triviality? \n # If the problem is too simple, maybe reject. But any integer works.\n # Let's just ensure the numbers are distinct enough to be interesting.\n if p1_m1 == p2_m2 and p1_m2 == p2_m1:\n continue\n \n # Construct the question\n question = (f\"In a job-shop scheduling problem, two machines (M1 and M2) process two jobs (J1 and J2). \"\n f\"Job J1 requires {p1_m1} minutes on M1 followed by {p1_m2} minutes on M2. \"\n f\"Job J2 requires {p2_m2} minutes on M2 followed by {p2_m1} minutes on M1. \"\n f\"The initial state is that both machines are idle. \"\n f\"Using the shortest processing time first rule for each machine as they become available, \"\n f\"what is the total makespan (completion time) when both jobs are finished?\")\n \n # Construct the lines\n lines = []\n lines.append(f\"At time 0, M1 starts J1 ({p1_m1} min) and M2 starts J2 ({p2_m2} min).\")\n \n t_m1_done = p1_m1\n t_m2_done = p2_m2\n \n if t_m1_done > t_m2_done:\n lines.append(f\"M2 completes J2 at time {t_m2_done} and idles until time {t_m1_done}.\")\n lines.append(f\"M1 completes J1 at time {t_m1_done}.\")\n lines.append(f\"At time {t_m1_done}, M1 starts J2 ({p2_m1} min) and M2 starts J1 ({p1_m2} min).\")\n elif t_m2_done > t_m1_done:\n lines.append(f\"M1 completes J1 at time {t_m1_done} and idles until time {t_m2_done}.\")\n lines.append(f\"M2 completes J2 at time {t_m2_done}.\")\n lines.append(f\"At time {t_m2_done}, M1 starts J2 ({p2_m1} min) and M2 starts J1 ({p1_m2} min).\")\n else:\n lines.append(f\"Both M1 and M2 complete their first jobs at time {t_m1_done}.\")\n lines.append(f\"At time {t_m1_done}, M1 starts J2 ({p2_m1} min) and M2 starts J1 ({p1_m2} min).\")\n \n lines.append(f\"M2 completes J1 at time {c1}.\")\n lines.append(f\"M1 completes J2 at time {c2}.\")\n lines.append(f\"The total makespan is the maximum completion time, which is {makespan}.\")\n \n return question, lines, str(makespan)\n \n return None\n"}
|
| 5 |
+
{"tid": "03207db004", "cat": "finance", "code": "import random\n\ndef make(rng, original=False):\n if original:\n question = (\"Consider a corporate bond issued by Nu Enterprises with a face value of $1,000, \"\n \"a coupon rate of 5% paid annually, and 5 years to maturity. \"\n \"If the current yield to maturity (YTM) is 6.5%, calculate the current market price of the bond to the nearest cent.\")\n lines = [\n \"Coupon = 0.05 \u00d7 1000 = 50\",\n \"Discount rate r = 0.065\",\n \"v = 1 / 1.065\",\n \"v^2 = 1 / 1.134225\",\n \"v^3 = 1 / 1.207949625\",\n \"v^4 = 1 / 1.286466350625\",\n \"v^5 = 1 / 1.370086663415625\",\n \"PV of coupon 1 = 50 \u00d7 v = 46.9483568075\",\n \"PV of coupon 2 = 50 \u00d7 v^2 = 44.0829641479\",\n \"PV of coupon 3 = 50 \u00d7 v^3 = 41.3924545990\",\n \"PV of coupon 4 = 50 \u00d7 v^4 = 38.8656850695\",\n \"PV of coupon 5 = 50 \u00d7 v^5 = 36.4940418217\",\n \"PV of face value = 1000 \u00d7 v^5 = 729.8808364340\",\n \"Sum of PVs = 46.9483568075 + 44.0829641479 + 41.3924545990 + 38.8656850695 + 36.4940418217 + 729.8808364340\",\n \"Sum of PVs = 937.6643388796\",\n \"Rounded to nearest cent = 937.66\"\n ]\n return (question, lines, \"$937.66\")\n\n # New parameters\n face = rng.choice([500, 1000, 2000, 5000])\n years = rng.randint(2, 10)\n # coupon rate 1%..12% in 0.5% steps\n coupon_rate = rng.choice([0.01, 0.015, 0.02, 0.025, 0.03, 0.035, 0.04, 0.045, 0.05, 0.055, 0.06, 0.065, 0.07, 0.075, 0.08, 0.085, 0.09, 0.095, 0.10, 0.105, 0.11, 0.115, 0.12])\n # YTM 1%..15% in 0.25% steps\n ytm = rng.choice([0.01, 0.0125, 0.015, 0.0175, 0.02, 0.0225, 0.025, 0.0275, 0.03, 0.0325, 0.035, 0.0375, 0.04, 0.0425, 0.045, 0.0475, 0.05, 0.0525, 0.055, 0.0575, 0.06, 0.0625, 0.065, 0.0675, 0.07, 0.0725, 0.075, 0.0775, 0.08, 0.0825, 0.085, 0.0875, 0.09, 0.0925, 0.095, 0.0975, 0.10, 0.1025, 0.105, 0.1075, 0.11, 0.1125, 0.115, 0.1175, 0.12, 0.1225, 0.125, 0.1275, 0.13, 0.1325, 0.135, 0.1375, 0.14, 0.1425, 0.145, 0.1475, 0.15])\n \n # Ensure coupon payment is a clean number (face * rate)\n coupon = face * coupon_rate\n # Avoid zero or negative\n if coupon <= 0:\n return None\n\n # Compute price\n v = 1.0 / (1.0 + ytm)\n price = 0.0\n for t in range(1, years + 1):\n price += coupon * (v ** t)\n price += face * (v ** years)\n\n # Reject if price is not finite or unreasonable\n if price <= 0 or price > face * 10:\n return None\n\n # Company name\n names = [\"Alpha\", \"Beta\", \"Gamma\", \"Delta\", \"Epsilon\", \"Zeta\", \"Eta\", \"Theta\", \"Iota\", \"Kappa\", \"Lambda\", \"Mu\", \"Nu\", \"Xi\", \"Omicron\", \"Pi\", \"Rho\", \"Sigma\", \"Tau\", \"Upsilon\", \"Phi\", \"Chi\", \"Psi\", \"Omega\"]\n suffixes = [\"Enterprises\", \"Corporation\", \"Industries\", \"Holdings\", \"Group\", \"Inc\", \"Ltd\", \"LLC\", \"Partners\", \"Systems\"]\n company = f\"{rng.choice(names)} {rng.choice(suffixes)}\"\n\n # Wording variation\n phrasing = rng.choice([\n \"calculate the current market price\",\n \"determine the current market value\",\n \"compute the current price\",\n \"find the current market price\"\n ])\n freq = rng.choice([\"annually\", \"once per year\", \"on an annual basis\"])\n \n question = (f\"Consider a corporate bond issued by {company} with a face value of ${face:,}, \"\n f\"a coupon rate of {coupon_rate*100:.1f}% paid {freq}, and {years} years to maturity. \"\n f\"If the current yield to maturity (YTM) is {ytm*100:.2f}%, {phrasing} of the bond to the nearest cent.\")\n\n lines = []\n lines.append(f\"Coupon = {coupon_rate:.4f} \u00d7 {face} = {coupon:.2f}\")\n lines.append(f\"Discount rate r = {ytm:.4f}\")\n for t in range(1, years + 1):\n vt = (1 + ytm) ** t\n lines.append(f\"v^{t} = 1 / {vt:.10f}\")\n for t in range(1, years + 1):\n pv = coupon * (v ** t)\n lines.append(f\"PV of coupon {t} = {coupon:.2f} \u00d7 v^{t} = {pv:.10f}\")\n pv_face = face * (v ** years)\n lines.append(f\"PV of face value = {face} \u00d7 v^{years} = {pv_face:.10f}\")\n \n # Sum line\n terms = []\n for t in range(1, years + 1):\n pv = coupon * (v ** t)\n terms.append(f\"{pv:.10f}\")\n terms.append(f\"{pv_face:.10f}\")\n lines.append(\"Sum of PVs = \" + \" + \".join(terms))\n lines.append(f\"Sum of PVs = {price:.10f}\")\n \n rounded = round(price, 2)\n lines.append(f\"Rounded to nearest cent = {rounded:.2f}\")\n \n answer = f\"${rounded:.2f}\"\n \n return (question, lines, answer)\n"}
|
| 6 |
+
{"tid": "2dd1d0a12f", "cat": "probability", "code": "import random\nfrom math import comb\nfrom fractions import Fraction\nimport itertools\n\ndef make(rng, original=False):\n if original:\n question = (\"In the Spadina station library, there are 12 distinct books: \"\n \"5 fiction, 4 non-fiction, and 3 reference. If a patron randomly \"\n \"selects 3 books from this collection without replacement, what is \"\n \"the probability that at least one of the selected books is a reference book?\")\n lines = [\n \"Total ways to select 3 books from 12: C(12, 3) = 220\",\n \"Total non-reference books: 5 + 4 = 9\",\n \"Ways to select 3 books with no reference: C(9, 3) = 84\",\n \"Probability of selecting no reference books: 84 / 220\",\n \"Probability of selecting at least one reference book: 1 - 84/220\",\n \"136 / 220\",\n \"34 / 55\",\n ]\n answer = \"34/55\"\n return question, lines, answer\n\n # Draw parameters\n # Categories: two \"other\" types and one \"target\" type\n # Ensure counts are positive and total is reasonable\n while True:\n a = rng.randint(3, 7)\n b = rng.randint(3, 7)\n c = rng.randint(2, 6)\n total = a + b + c\n k = rng.randint(2, min(4, total - 1))\n if total >= 6 and k <= total:\n break\n\n # Ensure non-triviality: probability not 0 or 1\n # P(at least one target) = 1 - C(a+b, k) / C(total, k)\n # This is 0 only if c=0 (not possible since c>=2)\n # This is 1 only if a+b < k (i.e., cannot pick k non-targets)\n if a + b < k:\n return None\n\n # Names\n adjectives = [\"Central\", \"North\", \"South\", \"East\", \"West\", \"Main\", \"Old\", \"New\", \"Grand\", \"Small\"]\n nouns = [\"Library\", \"Archive\", \"Museum\", \"Gallery\", \"Station\", \"Hall\", \"Room\", \"Center\"]\n adj = rng.choice(adjectives)\n noun = rng.choice(nouns)\n\n type_names = [\"fiction\", \"non-fiction\", \"reference\", \"biography\", \"history\", \"science\", \"art\", \"music\", \"travel\", \"cooking\"]\n # Shuffle to pick 3 distinct names\n names = rng.sample(type_names, 3)\n name_a, name_b, name_c = names\n\n # Construct question\n # Vary wording slightly\n templates = [\n f\"In the {adj} {noun}, there are {total} distinct items: {a} {name_a}, {b} {name_b}, and {c} {name_c}. \"\n f\"If a customer randomly selects {k} items from this collection without replacement, what is the \"\n f\"probability that at least one of the selected items is a {name_c}?\",\n f\"A collection at the {adj} {noun} contains {total} items: {a} are {name_a}, {b} are {name_b}, and {c} are {name_c}. \"\n f\"If {k} items are chosen at random without replacement, find the probability that at least one chosen item is a {name_c}.\",\n f\"There are {total} items in the {adj} {noun}: {a} {name_a}, {b} {name_b}, and {c} {name_c}. \"\n f\"What is the probability that a random selection of {k} items (without replacement) contains at least one {name_c}?\",\n ]\n question = rng.choice(templates)\n\n # Compute solution\n total_ways = comb(total, k)\n non_target = a + b\n no_target_ways = comb(non_target, k)\n \n p_no_target = Fraction(no_target_ways, total_ways)\n p_at_least_one = 1 - p_no_target\n \n if p_at_least_one.numerator == 0 or p_at_least_one.denominator == 0:\n return None\n\n # Construct lines\n lines = []\n lines.append(f\"Total ways to select {k} items from {total}: C({total}, {k}) = {total_ways}\")\n lines.append(f\"Total non-{name_c} items: {a} + {b} = {non_target}\")\n lines.append(f\"Ways to select {k} items with no {name_c}: C({non_target}, {k}) = {no_target_ways}\")\n lines.append(f\"Probability of selecting no {name_c} items: {no_target_ways} / {total_ways}\")\n lines.append(f\"Probability of selecting at least one {name_c} item: 1 - {no_target_ways}/{total_ways}\")\n \n # Simplify fraction steps if possible\n p_simp = p_at_least_one\n if p_simp.numerator != 1 or p_simp.denominator != 1:\n lines.append(f\"{p_simp.numerator} / {p_simp.denominator}\")\n \n answer = f\"{p_simp.numerator}/{p_simp.denominator}\"\n \n return question, lines, answer\n"}
|
| 7 |
+
{"tid": "30a3457665", "cat": "wordproblem", "code": "import random\n\n\ndef make(rng, original=False):\n if original:\n question = (\"The Hilsea bus route charges \u00a31.75 per zone. A passenger travels \"\n \"through 3 full zones and a half-zone surcharge of \u00a30.50. What is the total fare?\")\n lines = [\n f\"Full zones = 3\u00d71.75 = {3 * 1.75:.2f}\",\n f\"Add half-zone surcharge = {3 * 1.75:.2f} + 0.50 = {3 * 1.75 + 0.50:.2f}\",\n ]\n return question, lines, \"\u00a35.75\"\n\n # Draw new parameters\n # Fare per zone: multiples of 0.25 between 0.50 and 3.00\n fare = rng.choice([0.50, 0.75, 1.00, 1.25, 1.50, 1.75, 2.00, 2.25, 2.50, 2.75, 3.00])\n # Number of full zones: 1 to 5\n zones = rng.randint(1, 5)\n # Surcharge: 0.00 to 1.00 in steps of 0.25\n surcharge = rng.choice([0.00, 0.25, 0.50, 0.75, 1.00])\n \n # Reject trivial cases (e.g., 0 zones, 0 fare, 0 surcharge might be too easy but let's keep it simple)\n if fare == 0.0 or zones == 0:\n return None\n\n # Ensure the result is a clean decimal (no floating point issues)\n # Since we use multiples of 0.25, sum will be exact in binary? \n # 0.25 is 1/4, 0.50 is 1/2. Yes, these are exact in binary floating point.\n total = zones * fare + surcharge\n \n # Format to 2 decimal places\n total_str = f\"{total:.2f}\"\n \n # Construct question with varied wording\n route_names = [\"Hilsea\", \"Northbridge\", \"Eastgate\", \"Westford\", \"Southbank\"]\n route = rng.choice(route_names)\n \n # Vary the description of the surcharge\n if surcharge == 0.00:\n surcharge_desc = \"no additional surcharge\"\n elif surcharge == 0.25:\n surcharge_desc = \"a quarter-zone surcharge of \u00a30.25\"\n elif surcharge == 0.50:\n surcharge_desc = \"a half-zone surcharge of \u00a30.50\"\n elif surcharge == 0.75:\n surcharge_desc = \"a three-quarter zone surcharge of \u00a30.75\"\n else:\n surcharge_desc = \"a full extra zone surcharge of \u00a31.00\"\n\n question = (f\"The {route} bus route charges \u00a3{fare:.2f} per zone. A passenger travels \"\n f\"through {zones} full zones and {surcharge_desc}. What is the total fare?\")\n \n lines = [\n f\"Full zones = {zones}\u00d7{fare:.2f} = {zones * fare:.2f}\",\n f\"Add surcharge = {zones * fare:.2f} + {surcharge:.2f} = {total:.2f}\",\n ]\n \n answer = f\"\u00a3{total_str}\"\n \n return question, lines, answer\n"}
|
| 8 |
+
{"tid": "ab1665bd56", "cat": "probability", "code": "def make(rng, original=False):\n import math\n\n if original:\n question = (\"Hale Irwin\u2019s golf cart has a license plate with 4 characters, where the first \"\n \"character must be a consonant and the remaining three characters are digits (0-9). \"\n \"How many distinct license plates are possible?\")\n lines = [\n \"Total consonants in the English alphabet = 26 - 5 = 21\",\n \"Choices for the first character = 21\",\n \"Choices for the second character = 10\",\n \"Choices for the third character = 10\",\n \"Choices for the fourth character = 10\",\n \"Total distinct license plates = 21 * 10 * 10 * 10\",\n \"Total distinct license plates = 21 * 1000\",\n \"Total distinct license plates = 21000\",\n ]\n answer = \"21000\"\n return question, lines, answer\n\n # Choose a new scenario:\n # - total letters L (26), vowels V (5) -> consonants C = L - V\n # - plate length n (3..6), first char must be consonant, rest are digits (0..9)\n # To keep it non-trivial and similar, vary the length and sometimes the digit base.\n length = rng.choice([3, 4, 5, 6])\n digit_base = rng.choice([8, 10, 12]) # digits 0..digit_base-1\n\n # Sometimes swap the constraint: first char is a vowel, rest digits.\n first_is_vowel = rng.choice([False, True])\n\n consonants = 26 - 5\n vowels = 5\n first_choices = vowels if first_is_vowel else consonants\n digit_choices = digit_base\n\n total = first_choices * (digit_choices ** (length - 1))\n\n if total <= 0:\n return None\n\n # Build question with varied wording\n if first_is_vowel:\n first_desc = \"a vowel\"\n else:\n first_desc = \"a consonant\"\n\n if digit_base == 10:\n digit_desc = \"digits (0-9)\"\n else:\n digit_desc = f\"digits from 0 to {digit_base - 1}\"\n\n owner = rng.choice([\"Morgan\", \"Ellis\", \"Ravi\", \"Tessa\", \"Kip\", \"Nora\"])\n vehicle = rng.choice([\"bicycle\", \"kayak\", \"drone\", \"robot\", \"cart\", \"van\"])\n\n question = (\n f\"{owner}'s {vehicle} has a license plate with {length} characters, where the first \"\n f\"character must be {first_desc} and the remaining {length - 1} characters are {digit_desc}. \"\n f\"How many distinct license plates are possible?\"\n )\n\n # Build solution lines, computing every intermediate value in code.\n lines = []\n if first_is_vowel:\n lines.append(f\"Total vowels in the English alphabet = 5\")\n lines.append(f\"Choices for the first character = 5\")\n else:\n lines.append(f\"Total consonants in the English alphabet = 26 - 5 = {consonants}\")\n lines.append(f\"Choices for the first character = {consonants}\")\n\n for i in range(2, length + 1):\n lines.append(f\"Choices for the {i}th character = {digit_choices}\")\n\n # Show multiplication step-by-step\n acc = first_choices\n lines.append(f\"Total distinct license plates = {first_choices} * \" + \" * \".join([str(digit_choices)] * (length - 1)))\n for i in range(2, length + 1):\n acc = acc * digit_choices\n lines.append(f\"Total distinct license plates = {acc}\")\n\n answer = str(total)\n return question, lines, answer\n"}
|
| 9 |
+
{"tid": "747c13a169", "cat": "wordproblem", "code": "import random\n\ndef make(rng, original=False):\n if original:\n question = (\"A train departs from Beograd toward Sarajevo at 6:00 AM, traveling at a constant speed of 80 km/h. \"\n \"At 9:00 AM, a cyclist departs from Zagreb toward Beograd at a constant speed of 20 km/h. \"\n \"The distance between Beograd and Zagreb is 300 km, and the distance between Beograd and Sarajevo is 600 km. \"\n \"Assuming the train continues on its direct path to Sarajevo and the cyclist travels directly toward Beograd, \"\n \"calculate the distance in kilometers between the train and the cyclist at 12:00 PM, assuming all three cities \"\n \"lie on a straight line with Zagreb between Beograd and Sarajevo.\")\n lines = [\n \"Place Beograd at coordinate 0, Zagreb at 300, and Sarajevo at 600.\",\n \"The train travels from 6:00 AM to 12:00 PM, which is 6 hours.\",\n \"Train distance = 6 hours * 80 km/h = 480 km.\",\n \"Train position at 12:00 PM = 480 km.\",\n \"The cyclist travels from 9:00 AM to 12:00 PM, which is 3 hours.\",\n \"Cyclist distance = 3 hours * 20 km/h = 60 km.\",\n \"Cyclist starts at Zagreb (300 km) and moves toward Beograd (decreasing coordinate).\",\n \"Cyclist position at 12:00 PM = 300 km - 60 km = 240 km.\",\n \"Distance between train and cyclist = |480 km - 240 km| = 240 km.\",\n ]\n return question, lines, \"240\"\n\n # New random parameters\n # Cities: A (origin), B (between), C (far)\n # Train: A -> C, speed v1, start time t1\n # Cyclist: B -> A, speed v2, start time t2\n # Query time: tq\n # Ensure t1 < t2 < tq\n # Ensure distances and speeds yield integer results\n\n city_names = [\"Alpha\", \"Beta\", \"Gamma\", \"Delta\", \"Epsilon\", \"Zeta\", \"Eta\", \"Theta\"]\n rng.shuffle(city_names)\n A, B, C = city_names[0], city_names[1], city_names[2]\n\n # Distances\n d_AB = rng.randint(100, 500)\n d_AC = rng.randint(d_AB + 100, 1000)\n \n # Speeds\n v_train = rng.randint(40, 120)\n v_cyclist = rng.randint(10, 30)\n\n # Times (in hours, integers for simplicity)\n t_start_train = rng.randint(5, 7)\n t_start_cyclist = t_start_train + rng.randint(1, 3)\n t_query = t_start_cyclist + rng.randint(1, 4)\n\n # Ensure train hasn't reached C by t_query (optional, but good for \"on path\")\n # Train travel time = t_query - t_start_train\n # Train distance = (t_query - t_start_train) * v_train\n # If train distance > d_AC, it has passed C. The problem says \"toward C\", usually implies it's still on the way or we just calculate position.\n # Let's ensure it's still on the way to keep the \"toward\" semantics clean.\n train_time = t_query - t_start_train\n train_dist = train_time * v_train\n if train_dist >= d_AC:\n return None\n\n # Cyclist travel time\n cyclist_time = t_query - t_start_cyclist\n cyclist_dist = cyclist_time * v_cyclist\n \n # Cyclist must not have reached A (or passed it) to be \"toward A\" in a simple way?\n # If cyclist passes A, position becomes negative. The problem asks for distance between them.\n # Let's ensure cyclist is still between A and B or just past B but not past A?\n # \"Toward A\" from B. If it passes A, it's moving away from B.\n # Let's ensure cyclist hasn't reached A.\n if cyclist_dist >= d_AB:\n return None\n\n # Calculate positions\n pos_train = train_dist\n pos_cyclist = d_AB - cyclist_dist\n \n # Distance\n distance = abs(pos_train - pos_cyclist)\n\n # Check for ambiguity or triviality?\n if distance == 0:\n return None\n\n # Format question\n # Vary wording slightly\n templates = [\n f\"A train leaves {A} for {C} at {t_start_train}:00, moving at {v_train} km/h. A cyclist leaves {B} for {A} at {t_start_cyclist}:00, moving at {v_cyclist} km/h. The distance {A}-{B} is {d_AB} km and {A}-{C} is {d_AC} km. The cities are collinear with {B} between {A} and {C}. What is the distance between the train and cyclist at {t_query}:00?\",\n f\"At {t_start_train}:00, a train departs {A} heading to {C} at {v_train} km/h. At {t_start_cyclist}:00, a cyclist starts from {B} heading to {A} at {v_cyclist} km/h. Given {A}-{B} = {d_AB} km and {A}-{C} = {d_AC} km, and that {B} lies between {A} and {C} on a straight line, find the distance between them at {t_query}:00.\"\n ]\n question = rng.choice(templates)\n\n lines = [\n f\"Set {A} at coordinate 0, {B} at {d_AB}, and {C} at {d_AC}.\",\n f\"Train travel time from {t_start_train}:00 to {t_query}:00 is {train_time} hours.\",\n f\"Train distance = {train_time} * {v_train} = {train_dist} km.\",\n f\"Train position at {t_query}:00 is {pos_train} km.\",\n f\"Cyclist travel time from {t_start_cyclist}:00 to {t_query}:00 is {cyclist_time} hours.\",\n f\"Cyclist distance = {cyclist_time} * {v_cyclist} = {cyclist_dist} km.\",\n f\"Cyclist starts at {B} ({d_AB} km) and moves toward {A} (decreasing coordinate).\",\n f\"Cyclist position at {t_query}:00 is {d_AB} - {cyclist_dist} = {pos_cyclist} km.\",\n f\"Distance between train and cyclist = |{pos_train} - {pos_cyclist}| = {distance} km.\",\n ]\n\n return question, lines, str(distance)\n"}
|
| 10 |
+
{"tid": "37e22fa4e9", "cat": "wordproblem", "code": "import random\n\ndef make(rng, original=False):\n if original:\n return (\n \"Greebo Games releases a new board game every 3 months. If they started in January 2020, how many new games will they have released by the end of December 2022?\",\n [\n \"Jan 2020 to Dec 2022 = 3 years = 36 months\",\n \"36 months \u00f7 3 months per game = 12 games\",\n ],\n \"12\",\n )\n\n # Choose a new company name, game type, interval, and date range\n companies = [\"Moonlight Toys\", \"Pinecone Puzzles\", \"Starboard Studio\", \"Copper Kettle Games\", \"Willow & Oak\"]\n game_types = [\"board game\", \"puzzle\", \"card game\", \"strategy game\", \"family game\"]\n intervals = [2, 3, 4, 6]\n\n # Pick start and end years such that at least one full period fits\n start_year = rng.randint(2015, 2025)\n end_year = rng.randint(start_year + 1, start_year + 5)\n start_month = rng.randint(1, 12)\n end_month = rng.randint(1, 12)\n\n # Compute total months from start month to end of end_year\n total_months = (end_year - start_year) * 12 + (12 - start_month) + 1\n interval = rng.choice(intervals)\n\n if total_months < interval:\n return None\n\n count = total_months // interval\n if count < 1:\n return None\n\n company = rng.choice(companies)\n game = rng.choice(game_types)\n\n month_names = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\",\n \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"]\n start_str = f\"{month_names[start_month - 1]} {start_year}\"\n end_str = f\"December {end_year}\"\n\n question = (\n f\"{company} releases a new {game} every {interval} months. \"\n f\"If they started in {start_str}, how many new {game}s will they have released by the end of {end_str}?\"\n )\n\n lines = [\n f\"{start_str} to {end_str} = {total_months} months\",\n f\"{total_months} months \u00f7 {interval} months per {game} = {count} {game}s\",\n ]\n\n answer = str(count)\n return (question, lines, answer)\n"}
|
| 11 |
+
{"tid": "8c40d9b411", "cat": "wordproblem", "code": "import random\n\ndef make(rng, original=False):\n if original:\n question = (\"A book about Morgagni contains 240 pages. If a student reads 1/3 of the book \"\n \"on Monday and 40 pages on Tuesday, how many pages remain unread after Tuesday?\")\n lines = [\n \"1/3 of 240 = 80 pages read Monday\",\n \"80 + 40 = 120 pages read by Tuesday\",\n \"240 - 120 = 120 pages left\",\n ]\n return question, lines, \"120\"\n\n total = rng.choice([120, 150, 180, 210, 240, 270, 300, 330, 360, 420, 480])\n denom = rng.choice([2, 3, 4, 5, 6])\n if total % denom != 0:\n return None\n monday = total // denom\n tuesday = rng.randint(1, max(1, total - monday - 1))\n if monday + tuesday >= total:\n return None\n remaining = total - monday - tuesday\n if remaining <= 0:\n return None\n\n topic = rng.choice([\"Morgagni\", \"Galilei\", \"Newton\", \"Euler\", \"Fermat\", \"Descartes\", \"Hilbert\", \"Gauss\"])\n day1 = rng.choice([\"Monday\", \"Tuesday\", \"Wednesday\"])\n day2 = rng.choice([d for d in [\"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\"] if d != day1])\n\n question = (f\"A book about {topic} contains {total} pages. If a student reads 1/{denom} of the book \"\n f\"on {day1} and {tuesday} pages on {day2}, how many pages remain unread after {day2}?\")\n\n lines = [\n f\"1/{denom} of {total} = {monday} pages read {day1}\",\n f\"{monday} + {tuesday} = {monday + tuesday} pages read by {day2}\",\n f\"{total} - {monday + tuesday} = {remaining} pages left\",\n ]\n return question, lines, str(remaining)\n"}
|
| 12 |
+
{"tid": "ee2c250167", "cat": "finance", "code": "import random\n\ndef make(rng, original=False):\n if original:\n question = (\"An investor in a media holdings company purchases 1,500 shares at a price of $80 per share. \"\n \"After one year, the stock price rises to $95, and the company pays a dividend of $2.50 per share. \"\n \"Calculate the total percentage return on investment for the investor over this one-year period, \"\n \"rounded to two decimal places.\")\n lines = [\n \"Initial investment per share: $80\",\n \"Price appreciation per share: $95 - $80 = $15\",\n \"Dividend per share: $2.50\",\n \"Total gain per share: $15 + $2.50 = $17.50\",\n \"Percentage return: ($17.50 / $80) * 100\",\n \"Calculation: 0.21875 * 100 = 21.875%\",\n \"Rounding to two decimal places: 21.88%\",\n ]\n answer = \"21.88%\"\n return question, lines, answer\n\n # Draw new parameters\n buy_price = rng.randint(20, 200)\n # Ensure price rises\n sell_price = rng.randint(buy_price + 1, buy_price + 100)\n # Dividend: positive, reasonable\n dividend = round(rng.uniform(0.5, 5.0), 2)\n # Avoid exact terminating issues: ensure percentage return is not a pathological case\n # Compute return\n gain = sell_price - buy_price\n total_gain = gain + dividend\n pct = (total_gain / buy_price) * 100\n # Reject if rounding leads to ambiguity (e.g., exactly .xx5) - but Python round handles banker's rounding.\n # We reject if the value is very close to a half-cent boundary to avoid ambiguity.\n val = pct * 100 # in hundredths\n if abs(val - round(val)) < 1e-9 and round(val) % 1 == 0:\n # It's an integer percentage, which is fine, but let's just reject if it's suspiciously close to a .005 boundary\n pass\n # Reject if total_gain is zero or negative (shouldn't happen due to draw)\n if total_gain <= 0:\n return None\n\n # Wording variation\n companies = [\"tech\", \"energy\", \"pharma\", \"auto\", \"finance\"]\n company = rng.choice(companies) + \" holdings\"\n q = (f\"An investor in a {company} company purchases 1,200 shares at a price of ${buy_price} per share. \"\n f\"After one year, the stock price rises to ${sell_price}, and the company pays a dividend of ${dividend:.2f} per share. \"\n f\"Calculate the total percentage return on investment for the investor over this one-year period, \"\n f\"rounded to two decimal places.\")\n\n # Compute lines\n l1 = f\"Initial investment per share: ${buy_price}\"\n l2 = f\"Price appreciation per share: ${sell_price} - ${buy_price} = ${gain}\"\n l3 = f\"Dividend per share: ${dividend:.2f}\"\n l4 = f\"Total gain per share: ${gain} + ${dividend:.2f} = ${total_gain:.2f}\"\n l5 = f\"Percentage return: (${total_gain:.2f} / ${buy_price}) * 100\"\n l6 = f\"Calculation: {total_gain/buy_price:.5f} * 100 = {pct:.5f}%\"\n rounded = round(pct, 2)\n l7 = f\"Rounding to two decimal places: {rounded:.2f}%\"\n lines = [l1, l2, l3, l4, l5, l6, l7]\n answer = f\"{rounded:.2f}%\"\n return q, lines, answer\n"}
|
| 13 |
+
{"tid": "7a0bb3304b", "cat": "finance", "code": "import random\n\ndef make(rng, original=False):\n if original:\n question = (\"A local charity has fixed costs of \u00a312,000 per year and a variable cost of \u00a32 per donated item. \"\n \"If each item is sold for \u00a36, how many items must be sold to reach the break-even point?\")\n lines = [\n \"Fixed costs per year: \u00a312,000\",\n \"Variable cost per item: \u00a32\",\n \"Selling price per item: \u00a36\",\n \"Contribution per item = Selling price - Variable cost\",\n \"Contribution per item = \u00a36 - \u00a32\",\n \"Contribution per item = \u00a34\",\n \"Break-even quantity = Fixed costs / Contribution per item\",\n \"Break-even quantity = \u00a312,000 / \u00a34\",\n \"Break-even quantity = 3000\",\n ]\n answer = \"3000\"\n return question, lines, answer\n\n # Choose integers so the break-even quantity is an integer.\n # Contribution c = p - v must be positive and divide F.\n # Keep numbers moderate and non-trivial.\n while True:\n c = rng.randint(2, 12)\n v = rng.randint(1, c - 1)\n p = v + c\n q = rng.randint(100, 5000)\n F = q * c\n if F % c != 0:\n continue\n if p <= v:\n continue\n if q < 50:\n continue\n # Avoid trivially small values\n if F < 500:\n continue\n break\n\n # Vary wording slightly\n org = rng.choice([\"charity\", \"nonprofit\", \"community group\", \"fundraiser\"])\n item = rng.choice([\"item\", \"product\", \"good\", \"merchandise\"])\n qtext = (f\"A local {org} has fixed costs of \u00a3{F:,} per year and a variable cost of \u00a3{v} per {item}. \"\n f\"If each {item} is sold for \u00a3{p}, how many {item}s must be sold to reach the break-even point?\")\n\n lines = [\n f\"Fixed costs per year: \u00a3{F:,}\",\n f\"Variable cost per {item}: \u00a3{v}\",\n f\"Selling price per {item}: \u00a3{p}\",\n f\"Contribution per {item} = Selling price - Variable cost\",\n f\"Contribution per {item} = \u00a3{p} - \u00a3{v}\",\n f\"Contribution per {item} = \u00a3{c}\",\n f\"Break-even quantity = Fixed costs / Contribution per {item}\",\n f\"Break-even quantity = \u00a3{F:,} / \u00a3{c}\",\n f\"Break-even quantity = {q}\",\n ]\n answer = str(q)\n return qtext, lines, answer\n"}
|
| 14 |
+
{"tid": "21ad542f86", "cat": "finance", "code": "import random\n\ndef make(rng, original=False):\n if original:\n question = ('\"Cascade Coffee\" sells its signature roast for $12.00 per pound with a variable cost of $5.00 per pound. '\n 'The company has fixed monthly costs of $10,000 (including rent in a rain-sheltered roastery). '\n 'If the corporate tax rate is 25%, what is the minimum number of pounds of coffee that must be sold each month '\n 'to break even (i.e., achieve $0 net income after taxes)?')\n lines = [\n \"Contribution margin per pound = $12.00 - $5.00 = $7.00\",\n \"Pre-tax income = 7Q - 10,000\",\n \"After-tax net income = 0.75(7Q - 10,000)\",\n \"Set after-tax net income to 0: 0.75(7Q - 10,000) = 0\",\n \"7Q - 10,000 = 0\",\n \"7Q = 10,000\",\n \"Q = 10,000 / 7\",\n \"Q \u2248 1,428.57\",\n ]\n answer = \"1,428.57 pounds\"\n return question, lines, answer\n\n # Generate new problem parameters\n price = rng.randint(8, 20)\n var_cost = rng.randint(3, price - 2)\n fixed = rng.randint(5000, 20000)\n tax_rate = rng.choice([0.20, 0.25, 0.30])\n\n # Ensure contribution margin is positive\n cm = price - var_cost\n if cm <= 0:\n return None\n\n # Break-even quantity\n q = fixed / cm\n\n # Reject if non-terminating decimal (i.e., q is not a terminating decimal)\n # Check if q * 100 is close to an integer (2 decimal places)\n if abs(q * 100 - round(q * 100)) > 1e-9:\n return None\n\n # Format q to 2 decimal places\n q_str = f\"{q:.2f}\"\n\n # Build question\n brands = [\"Brew & Bean\", \"Morning Roast\", \"Summit Coffee\", \"Harbor Beans\", \"Alpine Brew\"]\n brand = rng.choice(brands)\n items = [\"coffee\", \"tea\", \"cocoa\", \"spices\"]\n item = rng.choice(items)\n units = [\"pounds\", \"kilograms\", \"bags\", \"boxes\"]\n unit = rng.choice(units)\n\n question = (f'\"{brand}\" sells its {item} for ${price:.2f} per {unit[:-1]} with a variable cost of ${var_cost:.2f} per {unit[:-1]}. '\n f'The company has fixed monthly costs of ${fixed:,} (including rent in a cozy shop). '\n f'If the corporate tax rate is {int(tax_rate*100)}%, what is the minimum number of {unit} that must be sold each month '\n f'to break even (i.e., achieve $0 net income after taxes)?')\n\n lines = [\n f\"Contribution margin per {unit[:-1]} = ${price:.2f} - ${var_cost:.2f} = ${cm:.2f}\",\n f\"Pre-tax income = {cm}Q - {fixed:,}\",\n f\"After-tax net income = {1-tax_rate:.2f}({cm}Q - {fixed:,})\",\n f\"Set after-tax net income to 0: {1-tax_rate:.2f}({cm}Q - {fixed:,}) = 0\",\n f\"{cm}Q - {fixed:,} = 0\",\n f\"{cm}Q = {fixed:,}\",\n f\"Q = {fixed:,} / {cm}\",\n f\"Q \u2248 {q_str}\",\n ]\n answer = f\"{q_str} {unit}\"\n\n return question, lines, answer\n"}
|
| 15 |
+
{"tid": "8d7ae3af60", "cat": "finance", "code": "import random\n\ndef make(rng, original=False):\n if original:\n income = 40000\n state_rate = 5\n federal_rate = 22\n lines = [\n \"Combined tax rate = 5% + 22% = 27%\",\n \"Taxable income = $40,000\",\n \"Total tax = 40,000 \u00d7 0.27\",\n \"Total tax = 10,800\",\n ]\n answer = \"10800\"\n question = (\"A Crouseville property owner earns $40,000 in taxable income this year. \"\n \"The local state tax rate is 5%, and the federal tax rate is 22%. \"\n \"Assuming no other deductions or credits, what is the total combined tax liability in dollars?\")\n return question, lines, answer\n\n # Draw new values\n income = rng.randint(10000, 200000)\n state_rate = rng.randint(1, 12)\n federal_rate = rng.randint(10, 35)\n\n # Avoid trivial cases: both rates must be positive (already true) and income positive (true)\n # Ensure combined rate is not 0 (true) and not 100% (unlikely but check)\n combined = state_rate + federal_rate\n if combined >= 100:\n return None\n\n # Compute answer\n total_tax = income * combined / 100\n # Check if it's an integer; if not, we could still accept but original uses integer.\n # Let's ensure it's an integer for clean output, or round if needed.\n # The original problem yielded an integer. Let's try to enforce integer result or just round.\n # To keep it simple and similar to original, we'll just compute and round to nearest int if needed,\n # but ideally we pick rates/income that yield integer.\n # Let's just compute and format. If it's not integer, we'll still return it but formatted.\n # However, the prompt says \"reject... non-terminating decimals where exact values are expected\".\n # Tax liabilities are often rounded to cents. Let's stick to integer dollars for simplicity like the original.\n # We can adjust income or rates to ensure divisibility, or just accept float and round.\n # Let's try to ensure integer result by picking income that is divisible by 100/gcd(100, combined)?\n # Simpler: just compute and round to nearest integer.\n \n total_tax_int = round(total_tax)\n \n # Check if rounding changed the value significantly (should be fine for this difficulty)\n \n lines = [\n f\"Combined tax rate = {state_rate}% + {federal_rate}% = {combined}%\",\n f\"Taxable income = ${income:,}\",\n f\"Total tax = {income:,} \u00d7 0.{combined:02d}\",\n f\"Total tax = ${total_tax_int:,}\",\n ]\n \n # Format answer without commas\n answer = str(total_tax_int)\n \n question = (f\"A property owner earns ${income:,} in taxable income this year. \"\n f\"The local state tax rate is {state_rate}%, and the federal tax rate is {federal_rate}%. \"\n f\"Assuming no other deductions or credits, what is the total combined tax liability in dollars?\")\n \n return question, lines, answer\n"}
|
| 16 |
+
{"tid": "4d39e4cf0c", "cat": "logic", "code": "import random\nimport math\n\ndef make(rng, original=False):\n if original:\n return (\n \"Four distinct towns\u2014Alpha, Beta, Gamma, and Delta\u2014are arranged in a line from north to south. The following clues are known to be true: Alpha is not immediately north of Beta. Gamma is exactly two towns away from Delta. Beta is immediately south of Alpha. Delta is not the southernmost town. Based on these constraints, what is the exact order of the towns from north to south?\",\n [\n \"Clue 3 states Beta is immediately south of Alpha, which implies Alpha is immediately north of Beta.\",\n \"Clue 1 states Alpha is not immediately north of Beta.\",\n \"These two conditions are mutually exclusive.\",\n \"Therefore, no arrangement of the four towns satisfies all the given constraints.\"\n ],\n \"No valid order\"\n )\n\n # Generate a consistent puzzle with a unique solution\n towns = [\"Alpha\", \"Beta\", \"Gamma\", \"Delta\"]\n rng.shuffle(towns)\n perm = tuple(towns) # ground truth order north->south\n pos = {t: i for i, t in enumerate(perm)}\n\n # Build clue set\n clues = []\n\n # Clue A: X is immediately north of Y (consistent with perm)\n i = rng.randint(0, 2)\n x, y = perm[i], perm[i + 1]\n clues.append((x, \"immediately north of\", y))\n\n # Clue B: Z is not immediately north of W (choose a pair NOT adjacent in that order)\n while True:\n z, w = rng.sample(towns, 2)\n if pos[z] + 1 != pos[w]:\n break\n clues.append((z, \"not immediately north of\", w))\n\n # Clue C: U is exactly two towns away from V (|pos diff| == 2)\n while True:\n u, v = rng.sample(towns, 2)\n if abs(pos[u] - pos[v]) == 2:\n break\n clues.append((u, \"exactly two towns away from\", v))\n\n # Clue D: T is not the southernmost town\n t = perm[0] # northernmost, definitely not southernmost\n clues.append((t, \"is not the southernmost town\", None))\n\n # Shuffle clue presentation order\n rng.shuffle(clues)\n\n # Brute-force verify uniqueness\n valid_perms = []\n for p in __import__(\"itertools\").permutations(towns):\n pp = {t: i for i, t in enumerate(p)}\n ok = True\n for c in clues:\n if c[1] == \"immediately north of\":\n if pp[c[0]] + 1 != pp[c[2]]:\n ok = False\n break\n elif c[1] == \"not immediately north of\":\n if pp[c[0]] + 1 == pp[c[2]]:\n ok = False\n break\n elif c[1] == \"exactly two towns away from\":\n if abs(pp[c[0]] - pp[c[2]]) != 2:\n ok = False\n break\n elif c[1] == \"is not the southernmost town\":\n if pp[c[0]] == 3:\n ok = False\n break\n if ok:\n valid_perms.append(p)\n\n if len(valid_perms) != 1:\n return None\n\n # Build question\n clue_strs = []\n for c in clues:\n if c[1] == \"immediately north of\":\n clue_strs.append(f\"{c[0]} is immediately north of {c[2]}.\")\n elif c[1] == \"not immediately north of\":\n clue_strs.append(f\"{c[0]} is not immediately north of {c[2]}.\")\n elif c[1] == \"exactly two towns away from\":\n clue_strs.append(f\"{c[0]} is exactly two towns away from {c[2]}.\")\n elif c[1] == \"is not the southernmost town\":\n clue_strs.append(f\"{c[0]} is not the southernmost town.\")\n\n question = (\n f\"Four distinct towns\u2014{', '.join(towns)}\u2014are arranged in a line from north to south. \"\n f\"The following clues are known to be true: {' '.join(clue_strs)} \"\n f\"Based on these constraints, what is the exact order of the towns from north to south?\"\n )\n\n # Build solution lines (deduction for the unique solution)\n lines = []\n sol = valid_perms[0]\n lines.append(f\"From the clues, we deduce the positions of each town.\")\n for idx, t in enumerate(sol):\n lines.append(f\"{t} is in position {idx + 1} (from north).\")\n lines.append(f\"Thus, the order from north to south is: {', '.join(sol)}.\")\n\n answer = \", \".join(sol)\n return (question, lines, answer)\n"}
|
| 17 |
+
{"tid": "d21b38427e", "cat": "planning", "code": "import random\n\ndef make(rng, original=False):\n if original:\n question = (\"Consider a routing protocol on a linear array of 5 servers indexed 0 to 4. \"\n \"A packet starts at server 0 and must reach server 4. At each step, the packet moves \"\n \"to an adjacent server (i-1 or i+1) but cannot visit server 0 again after leaving it. \"\n \"What is the length of the shortest path that visits servers 1, 2, and 3 at least once \"\n \"before reaching server 4?\")\n lines = [\"Start at server 0.\",\n \"Move to server 1 (step 1).\",\n \"Move to server 2 (step 2).\",\n \"Move to server 3 (step 3).\",\n \"Move to server 4 (step 4).\",\n \"Servers 1, 2, and 3 are visited before reaching server 4.\",\n \"Server 0 is not revisited.\",\n \"The path length is 4 steps.\"]\n answer = \"4\"\n return question, lines, answer\n\n n = rng.choice([5, 6, 7])\n start = 0\n end = n - 1\n required = list(range(1, end))\n required = rng.sample(required, rng.randint(1, len(required)))\n\n def valid(path):\n if path[0] != start or path[-1] != end:\n return False\n if len(set(path)) != len(path):\n return False\n if 0 in path[1:]:\n return False\n for i in range(len(path) - 1):\n if abs(path[i] - path[i + 1]) != 1:\n return False\n for r in required:\n if r not in path:\n return False\n return True\n\n best = None\n for L in range(len(required) + 1, 2 * n + 1):\n from itertools import product\n moves = [1, -1]\n found = False\n for delta in product(moves, repeat=L):\n path = [start]\n for d in delta:\n nxt = path[-1] + d\n if 0 <= nxt < n:\n path.append(nxt)\n if valid(path):\n best = L\n found = True\n break\n if found:\n break\n\n if best is None:\n return None\n\n req_str = \", \".join(str(r) for r in sorted(required))\n question = (f\"A packet travels on a line of {n} nodes numbered 0 to {n - 1}. \"\n f\"It starts at node {start} and must finish at node {end}. \"\n f\"Each move goes to an adjacent node, and node 0 may never be revisited after leaving. \"\n f\"Find the minimum number of moves for a path that visits nodes {req_str} at least once \"\n f\"before arriving at node {end}.\")\n\n lines = [f\"Start at node {start}.\",\n f\"The required nodes to visit are {req_str}.\",\n f\"Enumerating all valid walks of increasing length.\",\n f\"The shortest valid walk has length {best}.\"]\n answer = str(best)\n return question, lines, answer\n"}
|
| 18 |
+
{"tid": "78c044c23e", "cat": "wordproblem", "code": "import random\n\ndef make(rng, original=False):\n if original:\n question = (\"A biographer is compiling a timeline of a fictional mathematician's life. \"\n \"The sum of his ages at the times of his first, second, and third published papers is 84 years. \"\n \"The age at which he published his second paper was exactly one-third of his age when he published his third paper. \"\n \"If he published his first paper when he was 22 years old, determine his age when he published his third paper.\")\n lines = [\n \"Let the age at the second paper be x and the age at the third paper be y.\",\n \"The age at the first paper is 22.\",\n \"The sum of the ages is 84.\",\n \"22 + x + y = 84\",\n \"x + y = 62\",\n \"The age at the second paper is one-third of the age at the third paper.\",\n \"x = y/3\",\n \"Substitute x = y/3 into x + y = 62.\",\n \"y/3 + y = 62\",\n \"4y/3 = 62\",\n \"4y = 186\",\n \"y = 46.5\"\n ]\n answer = \"46.5\"\n return question, lines, answer\n\n # Draw new parameters\n # Choose first age\n first_age = rng.randint(15, 35)\n # Choose ratio: second = k * third, where k is 1/n for some small n\n # To keep it simple and similar, use fraction 1/n where n in {2,3,4,5}\n n = rng.choice([2, 3, 4, 5])\n # Choose third age such that second age = third_age / n is a \"nice\" number (integer or simple decimal)\n # We want the sum to be an integer, and the answer to be exact.\n # Let third_age = y, second_age = y/n\n # Sum = first_age + y/n + y = first_age + y*(1 + 1/n) = first_age + y*(n+1)/n\n # Let total_sum = S. Then y*(n+1)/n = S - first_age => y = n*(S - first_age)/(n+1)\n # We need y to be a valid age (positive, reasonable) and S to be an integer.\n # Let's pick S such that y is an integer or a simple fraction.\n # To ensure y is an integer, let S - first_age be a multiple of (n+1)/n ... \n # Actually, y = n * (S - first_age) / (n+1). For y to be integer, (S - first_age) must be divisible by (n+1)/gcd(n, n+1) = n+1.\n # So let S - first_age = k * (n+1) for some integer k >= 1.\n # Then y = n * k.\n # second_age = y / n = k.\n # Sum = first_age + k + n*k = first_age + k*(n+1).\n # This guarantees integer ages for second and third.\n # But the original problem had a non-integer answer (46.5). \n # The prompt says: \"reject ... non-terminating decimals where exact values are expected.\"\n # 46.5 is a terminating decimal. It is an exact value.\n # Let's allow non-integer y as long as it's exact.\n # If we allow y to be non-integer, we can just pick y from a set of values that are multiples of 0.5 or 0.25 etc.\n # Let's stick to the structure: x = y/n.\n # Let's pick y from a range of values that are multiples of 1/n to ensure x is an integer? \n # Or just pick y such that y/n is a \"nice\" number.\n # Let's pick y from a set of candidates:\n # Candidates for y: integers from 40 to 80, and halves (x.5) from 40.5 to 80.5.\n # If y is integer, x = y/n might not be integer.\n # Let's just pick y and x directly to satisfy x = y/n and x+y = S - first_age.\n # Let's pick x (second age) as an integer between 10 and 40.\n x = rng.randint(10, 40)\n # Then y = n * x\n y = n * x\n # Check if y is a reasonable age (e.g., < 100)\n if y >= 100:\n return None\n # Total sum\n total_sum = first_age + x + y\n # Ensure total_sum is an integer (it is)\n # Ensure the problem is not trivial (ages are distinct and increasing? Not required, but good)\n if not (first_age < x < y):\n # Allow non-strictly increasing? The problem says \"first, second, third\" which implies time order.\n # Ages should generally be non-decreasing. Let's enforce first <= second <= third.\n if not (first_age <= x <= y):\n return None\n \n # Construct question\n # Vary wording slightly\n subjects = [\"a fictional mathematician\", \"a renowned physicist\", \"a celebrated author\", \"a famous composer\"]\n subj = rng.choice(subjects)\n papers = [\"published papers\", \"major works\", \"landmark articles\", \"key publications\"]\n paper_type = rng.choice(papers)\n \n question = (f\"A biographer is compiling a timeline of {subj}'s life. \"\n f\"The sum of their ages at the times of their first, second, and third {paper_type} is {total_sum} years. \"\n f\"The age at which they published their second {paper_type.split()[0] if paper_type != 'major works' else 'work'} was exactly 1/{n} of their age when they published their third {paper_type.split()[0] if paper_type != 'major works' else 'work'}. \"\n f\"If they published their first {paper_type.split()[0] if paper_type != 'major works' else 'work'} when they were {first_age} years old, determine their age when they published their third {paper_type.split()[0] if paper_type != 'major works' else 'work'}.\")\n \n # Refine question for clarity\n if paper_type == \"major works\":\n noun = \"work\"\n else:\n noun = paper_type.split()[0]\n \n question = (f\"A biographer is compiling a timeline of {subj}'s life. \"\n f\"The sum of their ages at the times of their first, second, and third {paper_type} is {total_sum} years. \"\n f\"The age at which they published their second {noun} was exactly 1/{n} of their age when they published their third {noun}. \"\n f\"If they published their first {noun} when they were {first_age} years old, determine their age when they published their third {noun}.\")\n\n lines = [\n f\"Let the age at the second {noun} be x and the age at the third {noun} be y.\",\n f\"The age at the first {noun} is {first_age}.\",\n f\"The sum of the ages is {total_sum}.\",\n f\"{first_age} + x + y = {total_sum}\",\n f\"x + y = {total_sum - first_age}\",\n f\"The age at the second {noun} is 1/{n} of the age at the third {noun}.\",\n f\"x = y/{n}\",\n f\"Substitute x = y/{n} into x + y = {total_sum - first_age}.\",\n f\"y/{n} + y = {total_sum - first_age}\",\n f\"({n+1}y)/{n} = {total_sum - first_age}\",\n f\"({n+1}y) = {n * (total_sum - first_age)}\",\n f\"y = {n * (total_sum - first_age) / (n+1)}\"\n ]\n \n # Calculate answer\n y_val = n * (total_sum - first_age) / (n+1)\n # Format answer\n if y_val == int(y_val):\n answer = str(int(y_val))\n else:\n # Format to remove trailing zeros if it's a simple decimal\n answer = str(round(y_val, 2)).rstrip('0').rstrip('.')\n if '.' not in answer:\n answer = str(int(y_val))\n \n return question, lines, answer\n"}
|
| 19 |
+
{"tid": "ef42533737", "cat": "finance", "code": "import random\n\ndef make(rng, original=False):\n if original:\n fixed = 120000\n price = 20\n cost = 8\n margin = price - cost\n q = fixed // margin\n question = (\n \"Tully Marshall operates a small publishing company with a fixed cost of $120,000 per year. \"\n \"The marginal cost per book is $8, and the selling price per book is $20. \"\n \"Calculate the break-even quantity (in whole books) that the company must sell to avoid a net loss.\"\n )\n lines = [\n f\"Fixed cost = {fixed}\",\n f\"Selling price per book = {price}\",\n f\"Marginal cost per book = {cost}\",\n f\"Contribution margin per book = {price} - {cost}\",\n f\"Contribution margin per book = {margin}\",\n f\"Break-even quantity = {fixed} / {margin}\",\n f\"Break-even quantity = {q}\",\n ]\n return question, lines, str(q)\n\n # Generate a new problem\n # Choose fixed cost as a multiple of a chosen margin to ensure integer break-even\n # margin = price - cost, with price > cost\n # Try several random draws\n for _ in range(50):\n price = rng.randint(10, 100)\n cost = rng.randint(1, price - 1) # cost < price\n margin = price - cost\n # fixed cost should be a multiple of margin for exact integer\n mult = rng.randint(100, 2000)\n fixed = margin * mult\n # Ensure fixed cost is reasonable (e.g., between 10,000 and 2,000,000)\n if fixed < 10000 or fixed > 2000000:\n continue\n # Ensure margin is not too small to avoid trivially huge quantities\n if margin < 2:\n continue\n q = fixed // margin\n # Verify it divides exactly\n if fixed % margin != 0:\n continue\n # Ensure q is a reasonable whole number\n if q < 100 or q > 1000000:\n continue\n # We have a valid problem\n break\n else:\n return None\n\n # Slightly vary wording\n company_names = [\"Marshall Publishing\", \"BookWorks Ltd\", \"PageTurner Inc\", \"NovelPress Co\", \"InkWell Media\"]\n name = rng.choice(company_names)\n unit = rng.choice([\"book\", \"copy\", \"unit\"])\n \n question = (\n f\"{name} operates a small publishing company with a fixed cost of ${fixed:,} per year. \"\n f\"The marginal cost per {unit} is ${cost}, and the selling price per {unit} is ${price}. \"\n f\"Calculate the break-even quantity (in whole {unit}s) that the company must sell to avoid a net loss.\"\n )\n \n lines = [\n f\"Fixed cost = {fixed}\",\n f\"Selling price per {unit} = {price}\",\n f\"Marginal cost per {unit} = {cost}\",\n f\"Contribution margin per {unit} = {price} - {cost}\",\n f\"Contribution margin per {unit} = {margin}\",\n f\"Break-even quantity = {fixed} / {margin}\",\n f\"Break-even quantity = {q}\",\n ]\n \n return question, lines, str(q)\n"}
|
| 20 |
+
{"tid": "f206728e87", "cat": "probability", "code": "import random\nfrom fractions import Fraction\n\ndef make(rng, original=False):\n if original:\n question = (\"In a survey of 200 households, 120 watch a specific reality show, \"\n \"90 read a specific food blog, and 70 do both. If a household is selected \"\n \"at random from this group, what is the probability that the household \"\n \"does not watch the show and does not read the blog?\")\n lines = [\n \"Let A be the set of households that watch the show, with |A| = 120.\",\n \"Let B be the set of households that read the blog, with |B| = 90.\",\n \"The number of households that do both is |A \u2229 B| = 70.\",\n \"The total number of households is 200.\",\n \"The number of households that watch the show or read the blog is |A \u222a B| = |A| + |B| - |A \u2229 B|.\",\n \"|A \u222a B| = 120 + 90 - 70.\",\n \"|A \u222a B| = 140.\",\n \"The number of households that do neither is 200 - |A \u222a B|.\",\n \"200 - 140 = 60.\",\n \"The probability that a randomly selected household does neither is 60 / 200.\",\n \"60 / 200 = 3 / 10.\"\n ]\n answer = \"3/10\"\n return question, lines, answer\n\n # Generate random parameters\n total = rng.randint(100, 500)\n a = rng.randint(int(total * 0.2), int(total * 0.8))\n b = rng.randint(int(total * 0.2), int(total * 0.8))\n # Intersection must be <= min(a, b) and >= max(0, a + b - total)\n min_inter = max(0, a + b - total)\n max_inter = min(a, b)\n if min_inter > max_inter:\n return None\n inter = rng.randint(min_inter, max_inter)\n \n # Ensure the answer is not trivial (0 or 1) and simplifies nicely if possible, \n # but primarily just ensure it's a valid probability between 0 and 1.\n union = a + b - inter\n neither = total - union\n if neither <= 0 or neither >= total:\n return None\n \n prob = Fraction(neither, total)\n \n # Vary wording\n show_names = [\"a cooking show\", \"a drama series\", \"a sports league\", \"a news program\"]\n blog_names = [\"a tech blog\", \"a travel blog\", \"a finance blog\", \"a science blog\"]\n show = rng.choice(show_names)\n blog = rng.choice(blog_names)\n \n question = (f\"In a survey of {total} households, {a} watch {show}, \"\n f\"{b} read {blog}, and {inter} do both. If a household is selected \"\n f\"at random from this group, what is the probability that the household \"\n f\"does not watch {show} and does not read {blog}?\")\n \n lines = [\n f\"Let A be the set of households that watch {show}, with |A| = {a}.\",\n f\"Let B be the set of households that read {blog}, with |B| = {b}.\",\n f\"The number of households that do both is |A \u2229 B| = {inter}.\",\n f\"The total number of households is {total}.\",\n f\"The number of households that watch {show} or read {blog} is |A \u222a B| = |A| + |B| - |A \u2229 B|.\",\n f\"|A \u222a B| = {a} + {b} - {inter}.\",\n f\"|A \u222a B| = {union}.\",\n f\"The number of households that do neither is {total} - |A \u222a B|.\",\n f\"{total} - {union} = {neither}.\",\n f\"The probability that a randomly selected household does neither is {neither} / {total}.\",\n f\"{neither} / {total} = {prob.numerator} / {prob.denominator}.\"\n ]\n \n answer = f\"{prob.numerator}/{prob.denominator}\"\n \n return question, lines, answer\n"}
|
| 21 |
+
{"tid": "8a1c9604d4", "cat": "finance", "code": "import random\n\ndef make(rng, original=False):\n if original:\n P = 500\n r = 0.06\n n = 12\n t = 1\n A = P * (1 + r / n) ** (n * t)\n ans = f\"${round(A, 2):.2f}\"\n question = (\"In the summer of 1915, a Knoxville merchant deposits $500 into a savings account \"\n \"offering a nominal annual interest rate of 6% compounded monthly. \"\n \"Calculate the exact dollar amount in the account after exactly one year (12 months), \"\n \"rounding to the nearest cent.\")\n lines = [\n \"A = P(1 + r/n)^(nt)\",\n \"A = 500(1 + 0.06/12)^12\",\n \"A = 500(1 + 0.005)^12\",\n \"A = 500(1.005)^12\",\n f\"(1.005)^12 = {(1.005)**12}\",\n f\"A = 500({(1.005)**12})\",\n f\"A = {500 * (1.005)**12}\",\n f\"A = {round(500 * (1.005)**12, 2):.2f}\",\n ]\n return question, lines, ans\n\n # Generate new parameters\n P = rng.choice([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1500, 2000])\n r_pct = rng.choice([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15])\n r = r_pct / 100\n n = rng.choice([2, 4, 12, 365])\n t = rng.choice([1, 2, 3])\n\n A = P * (1 + r / n) ** (n * t)\n # Reject if rounding gives non-terminating issues (unlikely for 2 decimals, but check)\n ans_val = round(A, 2)\n ans = f\"${ans_val:.2f}\"\n\n # Build question with varied wording\n places = [\"Springfield\", \"Riverside\", \"Oakwood\", \"Maple Grove\", \"Hillcrest\"]\n years = [1920, 1935, 1950, 1975, 1990, 2005, 2015]\n seasons = [\"spring\", \"summer\", \"fall\", \"winter\"]\n roles = [\"merchant\", \"teacher\", \"engineer\", \"doctor\", \"farmer\"]\n place = rng.choice(places)\n year = rng.choice(years)\n season = rng.choice(seasons)\n role = rng.choice(roles)\n comp_desc = {2: \"semi-annually\", 4: \"quarterly\", 12: \"monthly\", 365: \"daily\"}[n]\n\n question = (f\"In the {season} of {year}, a {role} from {place} deposits ${P} into a savings account \"\n f\"offering a nominal annual interest rate of {r_pct}% compounded {comp_desc}. \"\n f\"Calculate the exact dollar amount in the account after exactly {t} year{'s' if t != 1 else ''} \"\n f\"({n*t} compounding periods), rounding to the nearest cent.\")\n\n lines = [\n \"A = P(1 + r/n)^(nt)\",\n f\"A = {P}(1 + {r}/{n})^{n*t}\",\n f\"A = {P}(1 + {r/n})^{n*t}\",\n f\"A = {P}({1 + r/n})^{n*t}\",\n f\"({1 + r/n})^{n*t} = {(1 + r/n)**(n*t)}\",\n f\"A = {P}({(1 + r/n)**(n*t)})\",\n f\"A = {A}\",\n f\"A = {ans_val:.2f}\",\n ]\n return question, lines, ans\n"}
|
| 22 |
+
{"tid": "23468dd2b3", "cat": "science_calc", "code": "import random\nimport math\n\ndef make(rng, original=False):\n if original:\n question = (\"A neuroimaging study compares the signal-to-noise ratio (SNR) of fMRI BOLD signals \"\n \"during sleep stages N3 and REM. If the SNR is inversely proportional to the square root \"\n \"of the number of independent trials N, and the N3 stage has 4 times the number of trials \"\n \"as the REM stage, by what factor is the SNR in the N3 stage higher than in the REM stage?\")\n lines = [\n \"SNR is inversely proportional to the square root of the number of trials, so SNR \u221d 1/\u221aN.\",\n \"Let N_REM be the number of trials in the REM stage.\",\n \"The number of trials in the N3 stage is N_N3 = 4 N_REM.\",\n \"The ratio of the SNR in N3 to the SNR in REM is (1/\u221aN_N3) / (1/\u221aN_REM).\",\n \"This ratio simplifies to \u221aN_REM / \u221aN_N3.\",\n \"Substituting N_N3 = 4 N_REM gives \u221aN_REM / \u221a(4 N_REM).\",\n \"This simplifies to 1/\u221a4.\",\n \"1/\u221a4 equals 1/2.\",\n \"1/2 equals 0.5.\",\n \"The SNR in the N3 stage is 0.5 times the SNR in the REM stage.\"\n ]\n answer = \"0.5\"\n return question, lines, answer\n\n # Draw a perfect-square multiplier k so the ratio is a clean decimal.\n # k = (integer)^2, choose integer m in [2,10]\n m = rng.randint(2, 10)\n k = m * m\n # Ensure k is a perfect square (it is by construction) and ratio = 1/m is a terminating decimal.\n # 1/m terminates iff m's prime factors are only 2 and 5.\n def terminates(m):\n while m % 2 == 0:\n m //= 2\n while m % 5 == 0:\n m //= 5\n return m == 1\n\n if not terminates(m):\n return None\n\n # Pick two stage names from a pool, distinct.\n stage_pool = [\"N1\", \"N2\", \"N3\", \"REM\", \"Wake\", \"Drowsy\", \"Deep\", \"Light\", \"Stage1\", \"Stage2\"]\n stages = rng.sample(stage_pool, 2)\n stage_a, stage_b = stages # stage_a has k times trials of stage_b\n\n # Wording variation\n intro_variants = [\n \"A neuroimaging study compares the signal-to-noise ratio (SNR) of fMRI BOLD signals during sleep stages {a} and {b}.\",\n \"Researchers measure the signal-to-noise ratio (SNR) of fMRI BOLD signals in sleep stages {a} and {b}.\",\n \"In a study of fMRI BOLD signals, the signal-to-noise ratio (SNR) is compared between sleep stages {a} and {b}.\",\n ]\n ratio_variants = [\n \"If the SNR is inversely proportional to the square root of the number of independent trials N, and stage {a} has {k} times the number of trials as stage {b}, by what factor is the SNR in stage {a} higher than in stage {b}?\",\n \"Given that SNR scales as the inverse square root of the number of independent trials N, and that stage {a} accumulates {k} times as many trials as stage {b}, what is the ratio of the SNR in stage {a} to that in stage {b}?\",\n ]\n intro = rng.choice(intro_variants).format(a=stage_a, b=stage_b)\n ratio_q = rng.choice(ratio_variants).format(a=stage_a, b=stage_b, k=k)\n question = intro + \" \" + ratio_q\n\n # Compute ratio = 1/m\n ratio = 1.0 / m\n # Round to a reasonable number of decimal places (original uses 1 decimal for 0.5)\n # Use up to 4 decimal places, strip trailing zeros\n ratio_str = f\"{ratio:.4f}\".rstrip(\"0\").rstrip(\".\")\n\n lines = [\n f\"SNR is inversely proportional to the square root of the number of trials, so SNR \u221d 1/\u221aN.\",\n f\"Let N_{stage_b} be the number of trials in stage {stage_b}.\",\n f\"The number of trials in stage {stage_a} is N_{stage_a} = {k} N_{stage_b}.\",\n f\"The ratio of the SNR in {stage_a} to the SNR in {stage_b} is (1/\u221aN_{stage_a}) / (1/\u221aN_{stage_b}).\",\n f\"This ratio simplifies to \u221aN_{stage_b} / \u221aN_{stage_a}.\",\n f\"Substituting N_{stage_a} = {k} N_{stage_b} gives \u221aN_{stage_b} / \u221a({k} N_{stage_b}).\",\n f\"This simplifies to 1/\u221a{k}.\",\n f\"\u221a{k} equals {m}.\",\n f\"1/{m} equals {ratio_str}.\",\n f\"The SNR in stage {stage_a} is {ratio_str} times the SNR in stage {stage_b}.\"\n ]\n answer = ratio_str\n return question, lines, answer\n"}
|
| 23 |
+
{"tid": "9983cb0b48", "cat": "wordproblem", "code": "import random\n\ndef make(rng, original=False):\n if original:\n q = (\"The 2008 Baltimore Ravens played 16 regular-season games. Suppose a fantasy football league scores players based on a complex formula: \"\n \"they earn 1 point for every 10 yards passed, 2 points for every 5 yards rushed, and 3 points for every 2 interceptions thrown. \"\n \"If the Ravens passed for 1,250 yards, rushed for 2,400 yards, and threw 10 interceptions over the entire season, \"\n \"what is the total score accumulated by the team according to this hypothetical formula?\")\n lines = [\n \"1250 / 10 = 125\",\n \"2400 / 5 = 480\",\n \"480 * 2 = 960\",\n \"10 / 2 = 5\",\n \"5 * 3 = 15\",\n \"125 + 960 = 1085\",\n \"1085 + 15 = 1100\"\n ]\n return q, lines, \"1100\"\n\n teams = [\"Ravens\", \"Cowboys\", \"Packers\", \"Bears\", \"Dolphins\", \"Bengals\"]\n team = rng.choice(teams)\n year = rng.randint(2000, 2023)\n # Points per unit\n p_passed = rng.randint(1, 3)\n p_rushed = rng.randint(1, 4)\n p_int = rng.randint(1, 5)\n # Divisors\n d_passed = rng.randint(2, 10)\n d_rushed = rng.randint(2, 10)\n d_int = rng.randint(1, 4)\n # Ensure integer divisions\n passed = rng.randint(1, 200) * d_passed\n rushed = rng.randint(1, 400) * d_rushed\n ints = rng.randint(0, 30) * d_int\n # Avoid trivial\n if passed == 0 and rushed == 0 and ints == 0:\n return None\n score_passed = (passed // d_passed) * p_passed\n score_rushed = (rushed // d_rushed) * p_rushed\n score_int = (ints // d_int) * p_int\n total = score_passed + score_rushed + score_int\n q = (f\"Suppose the {year} {team} fantasy stats are scored as follows: {p_passed} point(s) for every {d_passed} yards passed, \"\n f\"{p_rushed} point(s) for every {d_rushed} yards rushed, and {p_int} point(s) for every {d_int} interceptions thrown. \"\n f\"If the team passed for {passed:,} yards, rushed for {rushed:,} yards, and threw {ints} interceptions over the season, \"\n f\"what is the total score accumulated by the team according to this formula?\")\n lines = [\n f\"{passed} / {d_passed} = {passed // d_passed}\",\n f\"{passed // d_passed} * {p_passed} = {score_passed}\",\n f\"{rushed} / {d_rushed} = {rushed // d_rushed}\",\n f\"{rushed // d_rushed} * {p_rushed} = {score_rushed}\",\n f\"{ints} / {d_int} = {ints // d_int}\",\n f\"{ints // d_int} * {p_int} = {score_int}\",\n f\"{score_passed} + {score_rushed} = {score_passed + score_rushed}\",\n f\"{score_passed + score_rushed} + {score_int} = {total}\"\n ]\n return q, lines, str(total)\n"}
|
| 24 |
+
{"tid": "d3b63e0b68", "cat": "finance", "code": "import random\n\ndef make(rng, original=False):\n if original:\n principal = 50000\n loan_rate = 0.08\n bond_rate = 0.12\n question = (\"An investor borrows $50,000 from a bank at a simple annual interest rate of 8% \"\n \"to purchase a portfolio of corporate bonds yielding a 12% annual return. \"\n \"After one year, if the investor pays off the principal and interest from the bond proceeds, \"\n \"what is the investor's leveraged absolute profit in dollars?\")\n bond_return = principal * bond_rate\n loan_interest = principal * loan_rate\n profit = bond_return - loan_interest\n lines = [\n f\"Bond return: {principal:,} \u00d7 {bond_rate:.2f} = {bond_return:,.0f}\",\n f\"Loan interest: {principal:,} \u00d7 {loan_rate:.2f} = {loan_interest:,.0f}\",\n f\"Leveraged profit: {bond_return:,.0f} \u2212 {loan_interest:,.0f} = {profit:,.0f}\",\n ]\n answer = f\"${profit:,.0f}\"\n return question, lines, answer\n\n # Generate new numbers\n # Principal: multiples of 1000 between 10,000 and 100,000\n principal = rng.randint(10, 100) * 1000\n # Loan rate: integer percent between 4% and 10%\n loan_rate_pct = rng.randint(4, 10)\n # Bond rate: integer percent between loan_rate_pct+2 and loan_rate_pct+6\n bond_rate_pct = rng.randint(loan_rate_pct + 2, loan_rate_pct + 6)\n \n loan_rate = loan_rate_pct / 100.0\n bond_rate = bond_rate_pct / 100.0\n \n bond_return = principal * bond_rate\n loan_interest = principal * loan_rate\n profit = bond_return - loan_interest\n \n # Ensure profit is positive and not trivial\n if profit <= 0:\n return None\n \n # Check for non-terminating decimals (should be fine with integer percentages and multiples of 1000)\n # But just in case, verify values are clean\n if not (bond_return == int(bond_return) and loan_interest == int(loan_interest) and profit == int(profit)):\n return None\n \n bond_return = int(bond_return)\n loan_interest = int(loan_interest)\n profit = int(profit)\n \n # Vary wording slightly\n templates = [\n (\"An investor borrows ${principal:,} from a bank at a simple annual interest rate of {loan_rate_pct}% \"\n \"to purchase a portfolio of corporate bonds yielding a {bond_rate_pct}% annual return. \"\n \"After one year, if the investor pays off the principal and interest from the bond proceeds, \"\n \"what is the investor's leveraged absolute profit in dollars?\"),\n (\"A fund manager takes a ${principal:,} loan at {loan_rate_pct}% simple annual interest to invest in \"\n \"corporate bonds that pay {bond_rate_pct}% annually. One year later, after repaying the loan principal \"\n \"and interest using the bond income, what is the net leveraged profit in dollars?\"),\n (\"An investor leverages ${principal:,} at {loan_rate_pct}% simple interest to buy bonds yielding \"\n \"{bond_rate_pct}% per year. After one year, using bond proceeds to settle the loan, what is the \"\n \"absolute profit in dollars?\"),\n ]\n template = rng.choice(templates)\n question = template.format(principal=principal, loan_rate_pct=loan_rate_pct, bond_rate_pct=bond_rate_pct)\n \n lines = [\n f\"Bond return: {principal:,} \u00d7 {bond_rate:.2f} = {bond_return:,}\",\n f\"Loan interest: {principal:,} \u00d7 {loan_rate:.2f} = {loan_interest:,}\",\n f\"Leveraged profit: {bond_return:,} \u2212 {loan_interest:,} = {profit:,}\",\n ]\n answer = f\"${profit:,}\"\n \n return question, lines, answer\n"}
|
| 25 |
+
{"tid": "f9bc139277", "cat": "probability", "code": "def make(rng, original=False):\n import random\n if original:\n question = (\"A marketing team for Hunt Valley Towne Centre wants to create a promotional code \"\n \"consisting of 5 characters. The first 3 characters must be distinct uppercase letters \"\n \"from the alphabet, and the last 2 characters must be distinct digits from 0 to 9. \"\n \"If the code cannot contain the letter \\\"O\\\" or the digit \\\"0\\\" to avoid confusion, \"\n \"how many unique codes can be generated?\")\n lines = [\n \"Available uppercase letters excluding O: 26 - 1 = 25\",\n \"First character choices: 25\",\n \"Second character choices: 24\",\n \"Third character choices: 23\",\n \"Available digits excluding 0: 10 - 1 = 9\",\n \"Fourth character choices: 9\",\n \"Fifth character choices: 8\",\n \"Total codes: 25 * 24 * 23 * 9 * 8\",\n \"25 * 24 = 600\",\n \"600 * 23 = 13800\",\n \"9 * 8 = 72\",\n \"13800 * 72 = 993600\"\n ]\n answer = \"993600\"\n return (question, lines, answer)\n\n # Draw parameters\n total_letters = 26\n total_digits = 10\n n_letters = rng.randint(2, 4)\n n_digits = rng.randint(2, 4)\n total_len = n_letters + n_digits\n if total_len < 3 or total_len > 6:\n return None\n\n # Choose forbidden letters and digits\n forbidden_letters = rng.sample(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\", rng.randint(0, 2))\n forbidden_digits = rng.sample(\"0123456789\", rng.randint(0, 2))\n\n avail_letters = total_letters - len(forbidden_letters)\n avail_digits = total_digits - len(forbidden_digits)\n\n if avail_letters < n_letters or avail_digits < n_digits:\n return None\n\n # Compute total\n prod = 1\n for i in range(n_letters):\n prod *= (avail_letters - i)\n for i in range(n_digits):\n prod *= (avail_digits - i)\n\n # Build lines\n lines = []\n fl_str = \", \".join(f'\"{c}\"' for c in sorted(forbidden_letters)) if forbidden_letters else \"none\"\n fd_str = \", \".join(f'\"{c}\"' for c in sorted(forbidden_digits)) if forbidden_digits else \"none\"\n lines.append(f\"Available uppercase letters excluding {fl_str}: {total_letters} - {len(forbidden_letters)} = {avail_letters}\")\n for i in range(n_letters):\n lines.append(f\"Letter position {i+1} choices: {avail_letters - i}\")\n lines.append(f\"Available digits excluding {fd_str}: {total_digits} - {len(forbidden_digits)} = {avail_digits}\")\n for i in range(n_digits):\n lines.append(f\"Digit position {i+1} choices: {avail_digits - i}\")\n\n # Multiply step by step\n factors = [avail_letters - i for i in range(n_letters)] + [avail_digits - i for i in range(n_digits)]\n lines.append(f\"Total codes: {' * '.join(str(f) for f in factors)}\")\n running = 1\n for idx, f in enumerate(factors):\n running *= f\n if idx < len(factors) - 1:\n lines.append(f\"{running} = {' * '.join(str(x) for x in factors[:idx+1])}\")\n lines.append(f\"Result: {running}\")\n\n # Question\n fl_desc = \"the letter \" + \" or \".join(f'\"{c}\"' for c in sorted(forbidden_letters)) if forbidden_letters else \"no specific letters\"\n fd_desc = \"the digit \" + \" or \".join(f'\"{c}\"' for c in sorted(forbidden_digits)) if forbidden_digits else \"no specific digits\"\n question = (f\"A team wants to create a promotional code consisting of {total_len} characters. \"\n f\"The first {n_letters} characters must be distinct uppercase letters from the alphabet, \"\n f\"and the last {n_digits} characters must be distinct digits from 0 to 9. \"\n f\"If the code cannot contain {fl_desc} or {fd_desc} to avoid confusion, \"\n f\"how many unique codes can be generated?\")\n\n answer = str(running)\n return (question, lines, answer)\n"}
|
tmpl_code/tc_tp2c_1791582479_00007.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tmpl_code/tc_tp2c_1791582479_00008.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tmpl_code/tc_tp2c_1791582479_00009.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tmpl_code/tc_tp2c_1791582479_00010.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tmpl_code/tc_tp2c_1791582479_00011.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tmpl_code/tc_tp2c_1791582479_00012.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tmpl_code/tc_tp2c_1791582479_00013.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tmpl_code/tc_tp2c_1791582479_00014.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tmpl_code/tc_tp2c_1791582479_00015.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tmpl_code/tc_tp2c_1791582479_00016.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tmpl_code/tc_tp2c_1791582479_00017.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tmpl_code/tc_tp2c_1791582479_00018.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tmpl_code/tc_tp2c_1791582479_00019.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|