Asilarkness commited on
Commit
5b808e9
·
verified ·
1 Parent(s): ec67694

Upload tmpl_code/tc_tp1_1791579407_00002.jsonl with huggingface_hub

Browse files
tmpl_code/tc_tp1_1791579407_00002.jsonl ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {"tid": "c71a4279de", "cat": "wordproblem", "code": "def make(rng, original=False):\n def build_lines(singular, a, d, n):\n lines = []\n value = a\n for i in range(1, n + 1):\n if i == 1:\n lines.append(f\"{singular.capitalize()} {i}: {value}\")\n else:\n lines.append(f\"{singular.capitalize()} {i}: {value} + {d} = {value + d}\")\n value += d\n return lines, str(value)\n\n if original:\n question = (\n \"Morgagni\u2019s lecture series had 5 sessions. Each session had 2 more attendees \"\n \"than the previous one, starting with 18 attendees in the first session. \"\n \"How many attendees were there in the last session?\"\n )\n lines, answer = build_lines(\"session\", 18, 2, 5)\n return question, lines, answer\n\n names = [\n \"Alhazen\", \"Hypatia\", \"Euler\", \"Gauss\", \"Noether\",\n \"Turing\", \"Lovelace\", \"Fibonacci\", \"Pythagoras\",\n ]\n contexts = [\n (\"workshops\", \"workshop\", \"participants\"),\n (\"chapters\", \"chapter\", \"problems\"),\n (\"meetings\", \"meeting\", \"visitors\"),\n (\"lectures\", \"lecture\", \"students\"),\n (\"rounds\", \"round\", \"players\"),\n (\"tours\", \"tour\", \"visitors\"),\n (\"exams\", \"exam\", \"questions\"),\n (\"projects\", \"project\", \"tasks\"),\n ]\n\n while True:\n name = rng.choice(names)\n plural, singular, unit_plural = rng.choice(contexts)\n n = rng.randint(4, 8)\n d = rng.randint(2, 12)\n a = rng.randint(5, 60)\n if (n, d, a) == (5, 2, 18):\n continue\n break\n\n templates = [\n (\n \"{name}'s {plural} had {n} {plural}. Each {singular} had {d} more {unit_plural} \"\n \"than the previous one, starting with {a} {unit_plural} in the first {singular}. \"\n \"How many {unit_plural} were there in the last {singular}?\"\n ),\n (\n \"In {name}'s {plural}, the number of {unit_plural} increased by {d} from one \"\n \"{singular} to the next. The first {singular} had {a} {unit_plural}. \"\n \"If there were {n} {plural}, how many {unit_plural} were in the final {singular}?\"\n ),\n (\n \"{name} ran {n} {plural}. The first {singular} had {a} {unit_plural}, and each \"\n \"later {singular} had {d} more {unit_plural} than the one before it. \"\n \"How many {unit_plural} did the last {singular} have?\"\n ),\n ]\n\n question = rng.choice(templates).format(\n name=name,\n plural=plural,\n singular=singular,\n unit_plural=unit_plural,\n n=n,\n d=d,\n a=a,\n )\n\n lines, answer = build_lines(singular, a, d, n)\n return question, lines, answer\n"}
2
+ {"tid": "3a1e676128", "cat": "finance", "code": "def make(rng, original=False):\n import math\n\n if original:\n question = (\n 'The stock of \"Zorko Corp\" currently trades at $40 per share. '\n \"The company\u2019s earnings per share (EPS) for the last 12 months is $5, \"\n \"and its book value per share is $20. Calculate the Price-to-Earnings \"\n \"(P/E) ratio and the Price-to-Book (P/B) ratio.\"\n )\n price = 40\n eps = 5\n book = 20\n else:\n names = [\n \"Aster Corp\",\n \"Bramble Inc\",\n \"Cinder Ltd\",\n \"Delta Holdings\",\n \"Ember Group\",\n \"Fable Industries\",\n \"Grove Partners\",\n \"Harbor Co\",\n \"Iris Corp\",\n \"Jade Inc\",\n ]\n templates = [\n (\n 'The stock of \"{name}\" currently trades at ${price} per share. '\n \"The company\u2019s earnings per share (EPS) for the last 12 months is ${eps}, \"\n \"and its book value per share is ${book}. Calculate the Price-to-Earnings \"\n \"(P/E) ratio and the Price-to-Book (P/B) ratio.\"\n ),\n (\n 'Shares of \"{name}\" are trading at ${price}. '\n \"Its trailing 12-month earnings per share (EPS) is ${eps}, \"\n \"and its book value per share is ${book}. \"\n \"Find the Price-to-Earnings (P/E) ratio and the Price-to-Book (P/B) ratio.\"\n ),\n ]\n\n for _ in range(200):\n eps = rng.randint(2, 20)\n book = rng.randint(2, 20)\n if eps == book:\n continue\n\n lcm = eps * book // math.gcd(eps, book)\n multiplier = rng.randint(1, 6)\n price = lcm * multiplier\n\n pe = price // eps\n pb = price // book\n\n if pe == pb or pe <= 1 or pb <= 1:\n continue\n\n name = rng.choice(names)\n template = rng.choice(templates)\n question = template.format(name=name, price=price, eps=eps, book=book)\n break\n else:\n return None\n\n pe = price // eps\n pb = price // book\n\n lines = [\n \"Price-to-Earnings (P/E) ratio = Price per share / Earnings per share\",\n f\"P/E = {price} / {eps}\",\n f\"P/E = {pe}\",\n \"Price-to-Book (P/B) ratio = Price per share / Book value per share\",\n f\"P/B = {price} / {book}\",\n f\"P/B = {pb}\",\n ]\n\n answer = f\"P/E = {pe}; P/B = {pb}\"\n return question, lines, answer\n"}
3
+ {"tid": "a6571f94bc", "cat": "finance", "code": "def make(rng, original=False):\n def money(x):\n return f\"${x:,}\"\n\n if original:\n principal, rate, years = 1000, 5, 3\n interest_per_year = principal * rate // 100\n total = interest_per_year * years\n question = (\n \"A consumer invests $1,000 in a Pimpadelic-themed savings account \"\n \"that pays a simple annual interest rate of 5%. How much total interest \"\n \"will be earned after 3 years if the interest is not reinvested?\"\n )\n lines = [\n f\"Principal = {money(principal)}\",\n f\"Annual interest rate = {rate}% = {rate / 100:.2f}\",\n f\"Time = {years} years\",\n f\"Interest per year = {money(principal)} \\\\times {rate / 100:.2f} = {money(interest_per_year)}\",\n f\"Total interest = {money(interest_per_year)} \\\\times {years} = {money(total)}\",\n ]\n return question, lines, money(total)\n\n principals = [200, 300, 400, 500, 600, 700, 800, 900, 1000, 1200, 1500, 2000]\n rates = [2, 3, 4, 5, 6, 7, 8, 9, 10]\n year_choices = [2, 3, 4, 5]\n people = [\"consumer\", \"student\", \"teacher\", \"artist\", \"traveler\", \"musician\"]\n themes = [\"Cosmic\", \"Neon\", \"Retro\", \"Galaxy\", \"Jazz\", \"Pixel\", \"Safari\", \"Vintage\"]\n\n principal = rng.choice(principals)\n rate = rng.choice(rates)\n years = rng.choice(year_choices)\n person = rng.choice(people)\n theme = rng.choice(themes)\n\n if (principal * rate) % 100 != 0:\n return None\n\n interest_per_year = principal * rate // 100\n total = interest_per_year * years\n\n if total <= 0:\n return None\n\n rate_decimal = f\"{rate / 100:.2f}\"\n templates = [\n \"A {person} invests ${principal:,} in a {theme}-themed savings account that pays a simple annual interest rate of {rate}%. How much total interest will be earned after {years} years if the interest is not reinvested?\",\n \"Suppose a {person} deposits ${principal:,} into a {theme} savings account with a simple annual interest rate of {rate}%. If the interest is not reinvested, what is the total interest earned over {years} years?\",\n \"A {person} places ${principal:,} in a {theme}-themed account earning simple interest at {rate}% per year. How much interest will be earned in {years} years if the interest is not reinvested?\",\n ]\n\n question = rng.choice(templates).format(\n person=person,\n principal=principal,\n theme=theme,\n rate=rate,\n years=years,\n )\n\n lines = [\n f\"Principal = {money(principal)}\",\n f\"Annual interest rate = {rate}% = {rate_decimal}\",\n f\"Time = {years} years\",\n f\"Interest per year = {money(principal)} \\\\times {rate_decimal} = {money(interest_per_year)}\",\n f\"Total interest = {money(interest_per_year)} \\\\times {years} = {money(total)}\",\n ]\n\n return question, lines, money(total)\n"}
4
+ {"tid": "9c40747222", "cat": "science_calc", "code": "def make(rng, original=False):\n if original:\n d = 2.0\n d_text = f\"{d:.1f}\"\n question = (\n \"A student with nearsightedness (myopia) is maladjusted to distant objects; \"\n \"his far point is 2.0 m from his eye. Determine the optical power (in diopters) \"\n \"of the corrective lens required to allow him to see objects at infinity clearly, \"\n \"assuming the lens is placed directly in front of the eye.\"\n )\n else:\n d_choices = [0.5, 0.8, 1.25, 2.5, 4.0]\n d = rng.choice(d_choices)\n d_text = f\"{d:.2f}\"\n\n subjects = [\"A patient\", \"A person\", \"A student\", \"A driver\", \"A child\"]\n subject = rng.choice(subjects)\n\n templates = [\n \"{subject} with nearsightedness (myopia) cannot see distant objects clearly; \"\n \"their far point is {d} m from their eye. Determine the optical power (in diopters) \"\n \"of the corrective lens required to allow them to see objects at infinity clearly, \"\n \"assuming the lens is placed directly in front of the eye.\",\n \"{subject} is myopic, with a far point of {d} m. Find the power, in diopters, \"\n \"of the corrective lens that lets them see objects at infinity clearly, if the lens \"\n \"is placed directly in front of the eye.\",\n \"{subject} has a far point of {d} m due to myopia. What corrective lens power, in \"\n \"diopters, is needed for them to see objects at infinity clearly when the lens is \"\n \"placed directly in front of the eye?\",\n ]\n question = rng.choice(templates).format(subject=subject, d=d_text)\n\n if d <= 0:\n return None\n\n image_distance = -d\n inv_object = 0.0\n inv_image = 1.0 / image_distance\n power = inv_object + inv_image\n\n answer = f\"{power:.2f} D\"\n if answer == \"-0.00 D\":\n return None\n\n lines = [\n f\"The far point of the myopic eye is {d_text} m, so the corrective lens must form a virtual image of an object at infinity at this distance.\",\n f\"The object distance is d_o = infinity.\",\n f\"The image distance is d_i = -{d_text} m (negative because the image is virtual and on the same side as the object).\",\n f\"The lens equation is 1/f = 1/d_o + 1/d_i.\",\n f\"Substituting the values gives 1/f = 1/infinity + 1/(-{d_text}).\",\n f\"Since 1/infinity = 0, the equation simplifies to 1/f = {power:.2f} m^-1.\",\n f\"The optical power P is defined as P = 1/f where f is in meters.\",\n f\"Thus, P = {power:.2f} D.\",\n ]\n\n return question, lines, answer\n"}
5
+ {"tid": "9bb0c83f5b", "cat": "science_calc", "code": "from fractions import Fraction\n\ndef make(rng, original=False):\n def dec(fr):\n if fr < 0:\n return None\n n = fr.numerator\n d = fr.denominator\n if d == 1:\n return str(n)\n for k in range(1, 13):\n if 10 ** k % d == 0:\n break\n else:\n return None\n scaled = n * 10 ** k // d\n int_part = scaled // 10 ** k\n frac_part = scaled % 10 ** k\n frac_str = str(frac_part).zfill(k).rstrip(\"0\")\n if frac_str:\n return f\"{int_part}.{frac_str}\"\n return str(int_part)\n\n if original:\n question = \"In a biological study, a population of 1,000 buffalo bull calves exhibits a trait determined by a single gene with two alleles, $A$ and $a$. If the population is in Hardy-Weinberg equilibrium and the frequency of the homozygous dominant genotype ($AA$) is 0.25, what is the frequency of the heterozygous genotype ($Aa$) in the population (express as a decimal)?\"\n p = Fraction(1, 2)\n p2 = p * p\n q = 1 - p\n ans = 2 * p * q\n lines = [\n f\"p^2 = {dec(p2)}\",\n f\"p = {dec(p)}\",\n \"q = 1 - p\",\n f\"q = {dec(q)}\",\n f\"2pq = 2({dec(p)})({dec(q)})\",\n f\"2pq = {dec(ans)}\",\n ]\n return question, lines, dec(ans)\n\n species = rng.choice([\n \"buffalo bull calves\", \"zebra foals\", \"goat kids\", \"piglets\",\n \"sheep lambs\", \"cattle calves\", \"deer fawns\", \"rabbit kits\",\n ])\n pop = rng.choice([1000, 1500, 2000, 2500, 3000, 5000])\n dom = rng.choice([\"A\", \"B\", \"C\", \"D\", \"R\", \"S\"])\n lower = dom.lower()\n\n p = Fraction(rng.choice([1, 2, 3, 4, 6, 7, 8, 9]), 10)\n p2 = p * p\n q = 1 - p\n ans = 2 * p * q\n\n p2_s = dec(p2)\n p_s = dec(p)\n q_s = dec(q)\n ans_s = dec(ans)\n\n if None in (p2_s, p_s, q_s, ans_s):\n return None\n if p2_s in (\"0\", \"1\") or ans_s in (\"0\", \"1\"):\n return None\n\n templates = [\n \"In a biological study, a population of {pop} {species} exhibits a trait determined by a single gene with two alleles, ${dom}$ and ${lower}. If the population is in Hardy-Weinberg equilibrium and the frequency of the homozygous dominant genotype (${dom}{dom}) is {p2}, what is the frequency of the heterozygous genotype (${dom}{lower}) in the population (express as a decimal)?\",\n \"A population of {pop} {species} is in Hardy-Weinberg equilibrium for a single gene with alleles ${dom}$ and ${lower}. If the frequency of the homozygous dominant genotype (${dom}{dom}) is {p2}, what is the frequency of the heterozygous genotype (${dom}{lower}) (express as a decimal)?\",\n \"Researchers sampled {pop} {species} and found that a single-gene trait is in Hardy-Weinberg equilibrium. The alleles are ${dom}$ and ${lower}. If the frequency of the homozygous dominant genotype (${dom}{dom}) is {p2}, what is the frequency of the heterozygous genotype (${dom}{lower}) (express as a decimal)?\",\n ]\n\n question = rng.choice(templates).format(\n pop=f\"{pop:,}\",\n species=species,\n dom=dom,\n lower=lower,\n p2=p2_s,\n )\n\n lines = [\n f\"p^2 = {p2_s}\",\n f\"p = {p_s}\",\n \"q = 1 - p\",\n f\"q = {q_s}\",\n f\"2pq = 2({p_s})({q_s})\",\n f\"2pq = {ans_s}\",\n ]\n\n return question, lines, ans_s\n"}
6
+ {"tid": "6398f0da49", "cat": "wordproblem", "code": "def make(rng, original=False):\n if original:\n floors = 5\n rooms = 4\n chandeliers = 2\n total_rooms = floors * rooms\n total_chandeliers = total_rooms * chandeliers\n question = (\n f\"The King House has {floors} floors. \"\n f\"Each floor has {rooms} rooms, and each room contains {chandeliers} chandeliers. \"\n f\"How many chandeliers are in the entire house?\"\n )\n lines = [\n f\"{floors} floors \u00d7 {rooms} rooms = {total_rooms} rooms\",\n f\"{total_rooms} rooms \u00d7 {chandeliers} chandeliers = {total_chandeliers} chandeliers\",\n ]\n answer = str(total_chandeliers)\n return question, lines, answer\n\n building_noun = rng.choice([\"mansion\", \"hotel\", \"tower\", \"inn\", \"office building\"])\n building_prefix = rng.choice([\"The Grand\", \"The Willow\", \"The Blue\", \"The Old\", \"The Garden\", \"The Sunny\"])\n building_name = f\"{building_prefix} {building_noun.title()}\"\n\n unit_plural, unit_singular = rng.choice([\n (\"apartments\", \"apartment\"),\n (\"suites\", \"suite\"),\n (\"studios\", \"studio\"),\n (\"offices\", \"office\"),\n ])\n item_plural, item_singular = rng.choice([\n (\"lamps\", \"lamp\"),\n (\"vases\", \"vase\"),\n (\"mirrors\", \"mirror\"),\n (\"clocks\", \"clock\"),\n ])\n\n floors = rng.randint(3, 7)\n units = rng.randint(2, 6)\n items = rng.randint(2, 6)\n\n total_units = floors * units\n total_items = total_units * items\n\n if total_items < 24 or total_items == 40:\n return None\n\n sentences = [\n f\"{building_name} has {floors} floors.\",\n f\"Each floor has {units} {unit_plural}.\",\n f\"Each {unit_singular} contains {items} {item_plural}.\",\n ]\n rng.shuffle(sentences)\n\n final_question = rng.choice([\n f\"How many {item_plural} are in the entire {building_noun}?\",\n f\"How many {item_plural} are there in the whole {building_noun}?\",\n f\"What is the total number of {item_plural} in the entire {building_noun}?\",\n ])\n question = \" \".join(sentences) + \" \" + final_question\n\n lines = [\n f\"{floors} floors \u00d7 {units} {unit_plural} = {total_units} {unit_plural}\",\n f\"{total_units} {unit_plural} \u00d7 {items} {item_plural} = {total_items} {item_plural}\",\n ]\n answer = str(total_items)\n\n return question, lines, answer\n"}