Skip to content

Commit eb4dbb3

Browse files
committed
Updating walkthroughs
1 parent 6cf19f1 commit eb4dbb3

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/AoC_2023/Dazbo's_Advent_of_Code_2023.ipynb

+13-11
Original file line numberDiff line numberDiff line change
@@ -2314,7 +2314,7 @@
23142314
"Distance: 9 40 200\n",
23152315
"```\n",
23162316
"\n",
2317-
"Our boat starts at 0mm/ms. Charing of 1ms increases speed by 1mm/ms.\n",
2317+
"Our boat starts at 0mm/ms. Charging of 1ms increases speed by 1mm/ms.\n",
23182318
"\n",
23192319
"**Determine the number of ways you could beat the record in each race. What do you get if you multiply these numbers together?**\n",
23202320
"\n",
@@ -2335,17 +2335,15 @@
23352335
"outputs": [],
23362336
"source": [
23372337
"def solve_part1(data):\n",
2338-
" _, durations_part = data[0].split(\":\")\n",
2339-
" _, distances_part = data[1].split(\":\")\n",
2340-
" durations = [int(x) for x in durations_part.split()]\n",
2341-
" distances = [int(x) for x in distances_part.split()]\n",
2342-
" \n",
2338+
" durations = [int(x) for x in data[0].split(\":\")[1].split()]\n",
2339+
" distances = [int(x) for x in data[1].split(\":\")[1].split()]\n",
23432340
" logger.debug(f\"{durations=}\")\n",
23442341
" logger.debug(f\"{distances=}\")\n",
23452342
" \n",
23462343
" wins = defaultdict(dict) # { race_num: { hold_time: distance, hold_time: distance, ...} }\n",
23472344
" for i, duration in enumerate(durations): # e.g. 0, 7\n",
23482345
" for hold_time in range(1, duration): # e.g. 0-7\n",
2346+
" # d = (t - h) * h\n",
23492347
" d = (duration - hold_time) * hold_time\n",
23502348
" if d > distances[i]: # did we win?\n",
23512349
" wins[i][hold_time] = d\n",
@@ -2385,7 +2383,7 @@
23852383
"source": [
23862384
"### Day 6 Part 2\n",
23872385
"\n",
2388-
"Uh oh, there's only one race and the spaces should be ignored. E.g.\n",
2386+
"Uh oh, there's only one race and the spaces should be ignored. So we reinterpret the input like this:\n",
23892387
"\n",
23902388
"```text\n",
23912389
"Time: 71530\n",
@@ -2420,10 +2418,14 @@
24202418
"Remember the quadratic formula?\n",
24212419
"\n",
24222420
"$$\n",
2423-
"x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}\n",
2421+
"\\begin{align}\n",
2422+
"\\text{For: } ah^2 + bh + c &= 0 \\\\\n",
2423+
"\\notag \\\\\n",
2424+
"h &= \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}\n",
2425+
"\\end{align}\n",
24242426
"$$\n",
24252427
"\n",
2426-
"So we can use this to obtain the two roots, i.e. the hold times where where our distance is equal to the record distance. Using the sample data we were given:\n",
2428+
"So we can use this to obtain the two roots, i.e. the hold times where where our distance is equal to the record distance. We're given distance $d$ and one duration $t$ in our input. (And we know $a$ is `1`.) Using the sample data we were given:\n",
24272429
"\n",
24282430
"$$\n",
24292431
"h^2 - 71530h + 940200 = 0 \\\\\n",
@@ -9873,9 +9875,9 @@
98739875
"toc_visible": true
98749876
},
98759877
"kernelspec": {
9876-
"display_name": "aca_aoc",
9878+
"display_name": "ana-aoc",
98779879
"language": "python",
9878-
"name": "aca_aoc"
9880+
"name": "python3"
98799881
},
98809882
"language_info": {
98819883
"codemirror_mode": {

0 commit comments

Comments
 (0)