Asilarkness commited on
Commit
037fefe
·
verified ·
1 Parent(s): b4e21d6

Upload tmpl_code/tc_tp1_1791579407_00006.jsonl with huggingface_hub

Browse files
tmpl_code/tc_tp1_1791579407_00006.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {"tid": "c908560ec3", "cat": "wordproblem", "code": "def make(rng, original=False):\n from fractions import Fraction\n\n def round1(f):\n n = (20 * f.numerator + f.denominator) // (2 * f.denominator)\n return f\"{n // 10}.{n % 10}\"\n\n def dec(f):\n num, den = f.numerator, f.denominator\n d = den\n while d % 2 == 0:\n d //= 2\n while d % 5 == 0:\n d //= 5\n if d != 1:\n return None\n k = 0\n p = 1\n while p % den != 0:\n k += 1\n p *= 10\n s = num * (p // den)\n ip = s // p\n fp = s % p\n if fp == 0:\n return str(ip)\n return f\"{ip}.{fp:0{k}d}\"\n\n if original:\n a1, a2, q1, q2 = 500, 625, 20, 12\n question = (\n \"A Japanese electronics firm produces two models of laptops, Model A and Model B. \"\n \"Model A has a screen area of 500 cm\u00b2 and Model B has a screen area of 625 cm\u00b2. \"\n \"If a retailer mixes 20 units of Model A with 12 units of Model B, what is the average screen area per unit in the combined inventory, rounded to one decimal place?\"\n )\n total = q1 * a1 + q2 * a2\n units = q1 + q2\n avg = Fraction(total, units)\n avg_str = dec(avg)\n ans = round1(avg)\n lines = [\n f\"{q1} * {a1} = {q1 * a1}\",\n f\"{q2} * {a2} = {q2 * a2}\",\n f\"{q1 * a1} + {q2 * a2} = {total}\",\n f\"{q1} + {q2} = {units}\",\n f\"{total} / {units} = {avg_str}\",\n f\"{avg_str} rounded to one decimal place = {ans}\",\n ]\n return question, lines, ans\n\n companies = [\n \"A Japanese electronics firm\",\n \"A Korean electronics firm\",\n \"A European electronics firm\",\n \"A North American electronics firm\",\n \"An Australian electronics firm\",\n ]\n products = [\"laptop\", \"tablet\", \"monitor\", \"display\", \"all-in-one computer\"]\n names = [\n (\"Model A\", \"Model B\"),\n (\"Model X\", \"Model Y\"),\n (\"Type I\", \"Type II\"),\n (\"Version 1\", \"Version 2\"),\n ]\n templates = [\n \"{company} produces two {product} models, {name1} and {name2}. {name1} has a screen area of {a1} cm\u00b2 and {name2} has a screen area of {a2} cm\u00b2. If a retailer mixes {q1} units of {name1} with {q2} units of {name2}, what is the average screen area per unit in the combined inventory, rounded to one decimal place?\",\n \"{company} makes two {product} models, {name1} and {name2}. {name1} has a screen area of {a1} cm\u00b2, while {name2} has a screen area of {a2} cm\u00b2. A retailer combines {q1} units of {name1} with {q2} units of {name2}. What is the average screen area per unit in the combined stock, rounded to one decimal place?\",\n ]\n\n for _ in range(50):\n company = rng.choice(companies)\n product = rng.choice(products)\n name1, name2 = rng.choice(names)\n a1 = rng.randint(300, 900)\n a2 = rng.randint(300, 900)\n if abs(a1 - a2) < 50:\n continue\n q1 = rng.randint(5, 30)\n q2 = rng.randint(5, 30)\n\n total = q1 * a1 + q2 * a2\n units = q1 + q2\n avg = Fraction(total, units)\n avg_str = dec(avg)\n if avg_str is None:\n continue\n\n tenths = Fraction(total * 10, units)\n if tenths.denominator == 2 and tenths.numerator % 2 == 1:\n continue\n\n ans = round1(avg)\n if ans in (f\"{a1}.0\", f\"{a2}.0\"):\n continue\n\n question = rng.choice(templates).format(\n company=company,\n product=product,\n name1=name1,\n name2=name2,\n a1=a1,\n a2=a2,\n q1=q1,\n q2=q2,\n )\n lines = [\n f\"{q1} * {a1} = {q1 * a1}\",\n f\"{q2} * {a2} = {q2 * a2}\",\n f\"{q1 * a1} + {q2 * a2} = {total}\",\n f\"{q1} + {q2} = {units}\",\n f\"{total} / {units} = {avg_str}\",\n f\"{avg_str} rounded to one decimal place = {ans}\",\n ]\n return question, lines, ans\n\n return None\n"}
2
+ {"tid": "11809b9246", "cat": "finance", "code": "def make(rng, original=False):\n if original:\n P, R, T = 2_000_000, 6, 10\n question = (\n \"A football club takes out a $2,000,000 loan to renovate its stadium, \"\n \"borrowing at a simple interest rate of 6% per year for a 10-year term. \"\n \"If the club must repay the principal and total accumulated interest in a \"\n \"single lump sum at the end of year 10, what is the total repayment amount?\"\n )\n rate_str = f\"{R / 100:.2f}\"\n annual = P * R // 100\n interest = annual * T\n total = P + interest\n lines = [\n f\"Principal = {P:,}\",\n f\"Rate = {rate_str}\",\n f\"Time = {T}\",\n f\"Interest = {P:,} * {rate_str} * {T}\",\n f\"Interest = {annual:,} * {T}\",\n f\"Interest = {interest:,}\",\n f\"Total repayment = {P:,} + {interest:,}\",\n f\"Total repayment = {total:,}\",\n ]\n return question, lines, f\"${total:,}\"\n\n nouns = [\"bakery\", \"hospital\", \"school\", \"theater\", \"museum\", \"farm\", \"library\", \"restaurant\"]\n projects = [\n \"facility renovation\",\n \"equipment upgrade\",\n \"building expansion\",\n \"energy system upgrade\",\n \"new wing construction\",\n \"equipment replacement\",\n \"facility upgrade\",\n \"capital improvement\",\n ]\n templates = [\n \"A {noun} takes out a ${P:,} loan for its {project}, borrowing at a simple interest rate of {R}% per year for a {T}-year term. If the {noun} must repay the principal and total accumulated interest in a single lump sum at the end of year {T}, what is the total repayment amount?\",\n \"A {noun} borrows ${P:,} to fund a {project}. The loan uses simple interest at {R}% per year and matures in {T} years. The full principal plus all interest is due in one payment at the end of year {T}. What total amount will be repaid?\",\n \"To finance a {project}, a {noun} obtains a ${P:,} loan at simple interest of {R}% per year for {T} years. At maturity, the {noun} pays the original amount plus accumulated interest in one lump sum. How much must be repaid?\",\n ]\n\n principals = [\n 100_000, 150_000, 200_000, 250_000, 300_000,\n 400_000, 500_000, 600_000, 750_000, 1_000_000,\n 1_250_000, 1_500_000, 2_500_000, 3_000_000,\n ]\n rates = [r for r in range(2, 16) if r != 6]\n terms = [t for t in range(3, 16) if t != 10]\n\n P = rng.choice(principals)\n R = rng.choice(rates)\n T = rng.choice(terms)\n\n if P <= 0 or R <= 0 or T <= 0 or (P * R) % 100 != 0:\n return None\n\n noun = rng.choice(nouns)\n project = rng.choice(projects)\n template = rng.choice(templates)\n\n question = template.format(noun=noun, project=project, P=P, R=R, T=T)\n\n rate_str = f\"{R / 100:.2f}\"\n annual = P * R // 100\n interest = annual * T\n total = P + interest\n\n lines = [\n f\"Principal = {P:,}\",\n f\"Rate = {rate_str}\",\n f\"Time = {T}\",\n f\"Interest = {P:,} * {rate_str} * {T}\",\n f\"Interest = {annual:,} * {T}\",\n f\"Interest = {interest:,}\",\n f\"Total repayment = {P:,} + {interest:,}\",\n f\"Total repayment = {total:,}\",\n ]\n\n return question, lines, f\"${total:,}\"\n"}
3
+ {"tid": "487f7c84dc", "cat": "science_calc", "code": "def make(rng, original=False):\n import math\n from fractions import Fraction\n\n if original:\n g = 9.8\n L = 1.0\n g_eff = g / 2.0\n ratio = L / g_eff\n root = math.sqrt(ratio)\n T = 2.0 * math.pi * root\n\n lines = [\n \"T = 2\u03c0 \u221a(L / g_eff)\",\n \"g_eff = g / 2\",\n f\"g = {g} m/s\u00b2\",\n f\"g_eff = {g} / 2 = {g_eff} m/s\u00b2\",\n f\"L = {L} m\",\n f\"L / g_eff = {L} / {g_eff}\",\n f\"L / g_eff \u2248 {ratio:.7f}\",\n f\"\u221a(L / g_eff) \u2248 {root:.6f}\",\n f\"T = 2\u03c0 \u00d7 {root:.6f}\",\n f\"T \u2248 {T:.3f} s\",\n f\"T \u2248 {T:.2f} s\",\n ]\n\n question = (\n \"Consider a simple pendulum of length $L = 1.0$ m in a hypothetical scenario \"\n \"where Jer\u00f3nima is standing on a planet with half the gravitational acceleration \"\n \"of Earth ($g/2$). What is the period of oscillation for small amplitudes?\"\n )\n return question, lines, f\"{T:.2f} s\"\n\n names = [\n \"Amina\", \"Beto\", \"Celia\", \"Dario\", \"Elena\",\n \"Farid\", \"Greta\", \"Hiro\", \"Isla\", \"Jonas\",\n ]\n\n scales = [\n (Fraction(1, 2), \"half\"),\n (Fraction(3, 4), \"three-quarters\"),\n (Fraction(4, 5), \"four-fifths\"),\n (Fraction(5, 4), \"five-fourths\"),\n (Fraction(2, 1), \"twice\"),\n ]\n\n lengths = [0.6, 0.8, 1.2, 1.4, 1.6, 1.8, 2.2, 2.4, 2.8, 3.2, 3.6, 4.2]\n\n templates = [\n \"Consider a simple pendulum of length {L} m on a planet where {name} \"\n \"experiences {gravity_phrase}. What is the period of oscillation for small amplitudes?\",\n \"A simple pendulum of length {L} m is set up on a planet with {gravity_phrase}. \"\n \"If {name} is standing there, what is the period of small-amplitude oscillation?\",\n \"Suppose {name} is on a planet with {gravity_phrase}. \"\n \"A simple pendulum there has length {L} m. What is its period for small amplitudes?\",\n ]\n\n for _ in range(60):\n name = rng.choice(names)\n scale, scale_word = rng.choice(scales)\n L = rng.choice(lengths)\n\n g = 9.8\n g_eff = g * float(scale)\n ratio = L / g_eff\n root = math.sqrt(ratio)\n T = 2.0 * math.pi * root\n\n if T < 1.2 or T > 5.0:\n continue\n\n cents = T * 100.0\n frac = cents - math.floor(cents)\n if abs(frac - 0.5) < 0.05:\n continue\n\n if scale_word == \"twice\":\n gravity_phrase = \"twice Earth's gravitational acceleration\"\n else:\n gravity_phrase = f\"{scale_word} of Earth's gravitational acceleration\"\n\n template = rng.choice(templates)\n question = template.format(L=f\"{L:g}\", name=name, gravity_phrase=gravity_phrase)\n\n lines = [\n \"T = 2\u03c0 \u221a(L / g_eff)\",\n f\"g = {g} m/s\u00b2\",\n f\"g_eff = g \u00d7 {scale} = {g_eff:g} m/s\u00b2\",\n f\"L = {L:g} m\",\n f\"L / g_eff = {L:g} / {g_eff:g}\",\n f\"L / g_eff \u2248 {ratio:.7f}\",\n f\"\u221a(L / g_eff) \u2248 {root:.6f}\",\n f\"T = 2\u03c0 \u00d7 {root:.6f}\",\n f\"T \u2248 {T:.3f} s\",\n f\"T \u2248 {T:.2f} s\",\n ]\n\n return question, lines, f\"{T:.2f} s\"\n\n return None\n"}