Upload tmpl_code/tc_tp4_1791579464_00006.jsonl with huggingface_hub
Browse files
tmpl_code/tc_tp4_1791579464_00006.jsonl
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"tid": "0e4d0101aa", "cat": "logic", "code": "def make(rng, original=False):\n import itertools\n\n if original:\n names = [\"Alice\", \"Bob\", \"Carol\", \"Dave\"]\n p, q, r, s = \"Alice\", \"Bob\", \"Carol\", \"Dave\"\n question = (\n \"Four colleagues of B. Mutlu Sumer\u2014Alice, Bob, Carol, and Dave\u2014are arranging their desks in a single row with windows on the left side. \"\n \"Alice sits immediately to the left of Bob. Carol does not sit in the window seat. \"\n \"Dave sits somewhere to the right of Carol. If Bob is not in the furthest right seat, who sits in the window seat?\"\n )\n else:\n pool = [\"Ava\", \"Ben\", \"Cora\", \"Dana\", \"Eli\", \"Fay\", \"Gus\", \"Hana\", \"Iris\", \"Jude\", \"Kira\", \"Liam\"]\n names = rng.sample(pool, 4)\n p, q, r, s = rng.sample(names, 4)\n host = rng.choice([\"Morgan\", \"Riley\", \"Quinn\", \"Sam\", \"Taylor\", \"Jordan\"])\n\n intro = rng.choice([\n f\"Four colleagues of {host}\u2014{names[0]}, {names[1]}, {names[2]}, and {names[3]}\u2014are arranging their desks in a single row with windows on the left side.\",\n f\"Four friends of {host}\u2014{names[0]}, {names[1]}, {names[2]}, and {names[3]}\u2014are sitting in a row of four desks, with windows on the left.\",\n f\"Four coworkers of {host}\u2014{names[0]}, {names[1]}, {names[2]}, and {names[3]}\u2014place their desks in one row, windows on the left side.\"\n ])\n\n clue1 = f\"{p} sits immediately to the left of {q}.\"\n clue2 = f\"{r} does not sit in the window seat.\"\n clue3 = f\"{s} sits somewhere to the right of {r}.\"\n final = rng.choice([\n f\"If {q} is not in the furthest right seat, who sits in the window seat?\",\n f\"If {q} is not in the last seat, who sits in the window seat?\"\n ])\n\n clues = rng.sample([clue1, clue2, clue3], 3)\n question = f\"{intro} {' '.join(clues)} {final}\"\n\n window = 1\n last = len(names)\n a, b, c, d = range(1, last + 1)\n\n solutions = []\n for perm in itertools.permutations(names):\n pos = {name: i + 1 for i, name in enumerate(perm)}\n if (\n pos[p] + 1 == pos[q]\n and pos[r] != window\n and pos[s] > pos[r]\n and pos[q] != last\n ):\n solutions.append(perm)\n\n if len(solutions) != 1:\n return None\n\n answer = solutions[0][window - 1]\n if answer != p:\n return None\n\n lines = [\n f\"{p} immediately left of {q} means the pair occupies seats ({a},{b}), ({b},{c}), or ({c},{d}).\",\n f\"{q} is not in seat {d}, so the pair cannot be ({c},{d}).\",\n f\"If the pair is ({b},{c}), the remaining seats are {a} and {d}.\",\n f\"{r} cannot be in seat {a}, so {r} would be in seat {d} and {s} in seat {a}.\",\n f\"{s} must be to the right of {r}, but seat {a} is to the left of seat {d}, so this case is impossible.\",\n f\"Therefore, the pair must be in seats ({a},{b}), with {p} in seat {a} and {q} in seat {b}.\",\n f\"The remaining seats are {c} and {d} for {r} and {s}.\",\n f\"{s} must be to the right of {r}, so {r} is in seat {c} and {s} in seat {d}.\",\n f\"{p} is in seat {a}, which is the window seat.\"\n ]\n\n return question, lines, answer\n"}
|
| 2 |
+
{"tid": "9d04ba727c", "cat": "probability", "code": "def make(rng, original=False):\n import math\n from fractions import Fraction\n\n if original:\n question = 'An art museum curator is preparing a display case containing exactly 12 paintings by Wilfred Johnson. If the curator randomly selects 4 of these paintings to hang on the primary wall, what is the probability that the specific painting \"The Dancer\" (assuming it is one of the 12) is included in that selection? Express your answer as a simplified fraction.'\n n, k = 12, 4\n item = 'The Dancer'\n total = math.comb(n, k)\n favorable = math.comb(n - 1, k - 1)\n frac = Fraction(favorable, total)\n lines = [\n f\"Total number of ways to select {k} paintings from {n} is C({n}, {k}).\",\n f\"C({n}, {k}) = {total}.\",\n f'Number of ways to select {k} paintings including \"{item}\" is C({n - 1}, {k - 1}).',\n f\"C({n - 1}, {k - 1}) = {favorable}.\",\n f\"Probability is {favorable}/{total}.\",\n f\"Simplifying the fraction gives {frac.numerator}/{frac.denominator}.\"\n ]\n return question, lines, f\"{frac.numerator}/{frac.denominator}\"\n\n for _ in range(30):\n n = rng.randint(10, 18)\n k = rng.randint(3, n - 3)\n if (n, k) == (12, 4):\n continue\n prob = Fraction(k, n)\n if prob.denominator == 1:\n continue\n break\n else:\n return None\n\n object_sets = [\n (\"paintings\", \"museum\", \"artist\", \"painting\"),\n (\"books\", \"library\", \"author\", \"book\"),\n (\"posters\", \"gallery\", \"artist\", \"poster\"),\n (\"sculptures\", \"museum\", \"sculptor\", \"sculpture\"),\n (\"photographs\", \"gallery\", \"photographer\", \"photograph\"),\n ]\n plural, venue, maker_type, singular = rng.choice(object_sets)\n\n maker_names = [\"Elena Marsh\", \"Harold Vance\", \"Mira Chen\", \"Paul Okafor\", \"Lena Ortiz\", \"Samuel Reyes\"]\n item_names = [\"The Lighthouse\", \"The Wanderer\", \"The Orchard\", \"The Signal\", \"The Harbor\", \"The Meadow\", \"The Summit\", \"The River\"]\n maker_name = rng.choice(maker_names)\n item_name = rng.choice(item_names)\n\n templates = [\n f'A {venue} curator is preparing a display case containing exactly {n} {plural} by {maker_name}. If the curator randomly selects {k} of these {plural} for the primary display, what is the probability that the specific {singular} \"{item_name}\" (assuming it is one of the {n}) is included in that selection? Express your answer as a simplified fraction.',\n f'A {venue} has exactly {n} {plural} by {maker_name}. A random selection of {k} {plural} will be made for the primary exhibit. What is the probability that the specific {singular} \"{item_name}\" (one of the {n}) is included? Express your answer as a simplified fraction.',\n f'From a set of exactly {n} {plural} by {maker_name}, a {venue} will randomly choose {k} {plural} for its main exhibit. If the specific {singular} \"{item_name}\" is among the {n}, what is the probability it is chosen? Express your answer as a simplified fraction.'\n ]\n question = rng.choice(templates)\n\n total = math.comb(n, k)\n favorable = math.comb(n - 1, k - 1)\n frac = Fraction(favorable, total)\n lines = [\n f\"Total ways to choose {k} {plural} from {n} is C({n}, {k}).\",\n f\"C({n}, {k}) = {total}.\",\n f'Ways to choose {k} {plural} including \"{item_name}\" is C({n - 1}, {k - 1}).',\n f\"C({n - 1}, {k - 1}) = {favorable}.\",\n f\"Probability is {favorable}/{total}.\",\n f\"Simplified probability is {frac.numerator}/{frac.denominator}.\"\n ]\n return question, lines, f\"{frac.numerator}/{frac.denominator}\"\n"}
|
| 3 |
+
{"tid": "83af58cfee", "cat": "science_calc", "code": "from fractions import Fraction\n\ndef make(rng, original=False):\n def fmt(value):\n f = Fraction(value)\n if f.denominator == 1:\n return str(f.numerator)\n p = 1\n while p % f.denominator != 0:\n p *= 10\n num = f.numerator * p // f.denominator\n s = str(num)\n m = len(str(p)) - 1\n if m == 0:\n return s\n if len(s) <= m:\n s = \"0\" * (m - len(s)) + s\n whole, frac = s[:-m], s[-m:]\n frac = frac.rstrip(\"0\")\n return whole + (\".\" + frac if frac else \"\")\n\n if original:\n e = Fraction(\"0.8\")\n h = Fraction(10)\n g = Fraction(\"9.8\")\n question = (\n \"A 2.5 kg ball is dropped from a height of 10 m onto a rigid surface. \"\n \"If the coefficient of restitution is 0.8, calculate the height (in meters) \"\n \"to which the ball rises after the first bounce.\"\n )\n else:\n for _ in range(30):\n mass_s = rng.choice([\"1\", \"1.5\", \"2\", \"2.5\", \"3\", \"4\", \"5\", \"6\", \"7.5\"])\n h = Fraction(rng.choice([10, 20, 30, 40, 50]))\n e = Fraction(rng.choice([\"0.5\", \"0.6\", \"0.7\", \"0.8\", \"0.9\"]))\n if h == Fraction(10) and e == Fraction(\"0.8\"):\n continue\n if (e * e * h).denominator == 1:\n continue\n break\n else:\n return None\n\n obj = rng.choice([\"ball\", \"sphere\", \"puck\", \"block\"])\n g = Fraction(\"9.8\")\n mass_s = fmt(mass_s)\n h_s = fmt(h)\n e_s = fmt(e)\n style = rng.randint(0, 2)\n\n if style == 0:\n question = (\n f\"A {mass_s} kg {obj} is dropped from a height of {h_s} m onto a rigid surface. \"\n f\"If the coefficient of restitution is {e_s}, calculate the height (in meters) \"\n f\"to which the {obj} rises after the first bounce.\"\n )\n elif style == 1:\n question = (\n f\"A {mass_s} kg {obj} falls from {h_s} m to a rigid floor. \"\n f\"Given a coefficient of restitution of {e_s}, what height in meters \"\n f\"does it reach after the first bounce?\"\n )\n else:\n question = (\n f\"If a {mass_s} kg {obj} is released from {h_s} m above a rigid surface \"\n f\"and the coefficient of restitution is {e_s}, find the rebound height \"\n f\"in meters after the first bounce.\"\n )\n\n e2 = e * e\n answer = fmt(e2 * h)\n\n lines = [\n f\"Velocity just before impact: v = sqrt(2*g*h) = sqrt(2 * {fmt(g)} * {fmt(h)})\",\n f\"Velocity just after impact: v' = e * v = {fmt(e)} * sqrt(2 * {fmt(g)} * {fmt(h)})\",\n f\"Height after bounce: h' = (v')^2 / (2g) = ({fmt(e)})^2 * (2 * {fmt(g)} * {fmt(h)}) / (2 * {fmt(g)})\",\n f\"h' = {fmt(e2)} * {fmt(h)}\",\n f\"h' = {answer}\",\n ]\n\n return question, lines, answer\n"}
|
| 4 |
+
{"tid": "79b23051c4", "cat": "wordproblem", "code": "def make(rng, original=False):\n if original:\n total = 7200\n total_hours = 12\n first_hours = 3\n percent = 25\n first = total * percent // 100\n remaining = total - first\n\n question = (\n \"The flight computer logged 7,200 error codes over a 12-hour period. \"\n \"If 25 % of the errors occurred during the first 3 hours, \"\n \"how many errors occurred in the remaining 9 hours?\"\n )\n lines = [\n f\"Errors in first {first_hours} h = {percent / 100:.2f} \u00d7 {total} = {first}\",\n f\"Errors in remaining {total_hours - first_hours} h = {total} \u2013 {first} = {remaining}\",\n ]\n return question, lines, str(remaining)\n\n devices = [\n \"flight computer\",\n \"network monitor\",\n \"manufacturing controller\",\n \"weather station\",\n \"security system\",\n \"database server\",\n ]\n\n templates = [\n \"The {device} logged {total} error codes over a {total_hours}-hour period. \"\n \"If {percent} % of the errors occurred during the first {first_hours_str}, \"\n \"how many errors occurred in the remaining {remaining_hours_str}?\",\n\n \"A {device} recorded {total} error codes in {total_hours} hours. \"\n \"If {percent} % of the errors occurred in the first {first_hours_str}, \"\n \"how many errors occurred in the remaining {remaining_hours_str}?\",\n\n \"During a {total_hours}-hour shift, a {device} logged {total} error codes. \"\n \"If {percent} % of the errors appeared in the first {first_hours_str}, \"\n \"how many appeared in the remaining {remaining_hours_str}?\",\n ]\n\n percents = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50,\n 55, 60, 65, 70, 75, 80, 85, 90, 95]\n\n for _ in range(100):\n total = rng.randrange(50, 500) * 20\n total_hours = rng.randint(8, 24)\n first_hours = rng.randint(1, total_hours - 1)\n percent = rng.choice(percents)\n\n if total == 7200 and total_hours == 12 and first_hours == 3 and percent == 25:\n continue\n if total * percent % 100 != 0:\n continue\n\n remaining_hours = total_hours - first_hours\n first = total * percent // 100\n remaining = total - first\n\n if first <= 0 or remaining <= 0:\n continue\n\n first_hours_str = \"1 hour\" if first_hours == 1 else f\"{first_hours} hours\"\n remaining_hours_str = \"1 hour\" if remaining_hours == 1 else f\"{remaining_hours} hours\"\n\n device = rng.choice(devices)\n template = rng.choice(templates)\n\n question = template.format(\n device=device,\n total=f\"{total:,}\",\n total_hours=total_hours,\n percent=percent,\n first_hours_str=first_hours_str,\n remaining_hours_str=remaining_hours_str,\n )\n\n lines = [\n f\"Errors in first {first_hours} h = {percent / 100:.2f} \u00d7 {total} = {first}\",\n f\"Errors in remaining {remaining_hours} h = {total} \u2013 {first} = {remaining}\",\n ]\n\n return question, lines, str(remaining)\n\n return None\n"}
|