Skip to content

Commit

Permalink
Starting pt 2
Browse files Browse the repository at this point in the history
  • Loading branch information
derailed-dash committed Dec 28, 2023
1 parent 19c1228 commit e5db577
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/AoC_2023/Dazbo's_Advent_of_Code_2023.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
},
"outputs": [],
"source": [
"%pip install jupyterlab-lsp colorama python-dotenv ipykernel ffmpeg graphviz mediapy"
"%pip install jupyterlab-lsp colorama python-dotenv ipykernel ffmpeg graphviz mediapy sympy"
]
},
{
Expand All @@ -84,6 +84,7 @@
"from collections import Counter, deque, defaultdict\n",
"from io import BytesIO\n",
"import abc\n",
"import ast\n",
"import heapq\n",
"import copy\n",
"import operator\n",
Expand All @@ -92,7 +93,7 @@
"import os\n",
"import platform\n",
"import re\n",
"import ast\n",
"import sympy\n",
"import unittest\n",
"import requests\n",
"import imageio.v3 as iio\n",
Expand Down Expand Up @@ -9429,7 +9430,29 @@
"We can throw a rock that can reach any integer location and with any integer velocity. We want the rock to collide with EVERY hailstone. The rock itself won't change position or velocity when it hits a hailstone.\n",
"\n",
"**Determine the exact position and velocity the rock needs to have at time 0 so that it perfectly collides with every hailstone. What do you get if you add up the X, Y, and Z coordinates of that initial position?**\n",
"\n"
"\n",
"We can determine the time `t` when the rock (`r`) will hit a hailstone (`h`). Recall that location is given by initial location, plus `time * velocity`.\n",
"\n",
"First, in the `x` direction only:\n",
"\n",
"$$\n",
"\\begin{align}\n",
"\\text{Let } & x_{h}\\text{ be the location of the hailstone} \\notag \\\\\n",
"& x_{r}\\text{ be the location of the rock} \\notag \\\\\n",
"& v_{x_{h}}\\text{ be the x velocity of the hailstone} \\notag \\\\\n",
"& v_{x_{r}}\\text{ be the x velocity of the hailstone} \\notag \\\\\n",
"\\notag \\\\ \n",
"x_{h} + tv_{x_{h}} &= x_{r} + tv_{x_{r}} \\\\\n",
"tv_{x_{h}} - tv_{x_{r}} &= x_{r} - x_{h} \\\\\n",
"t &= \\frac{x_{r} - x_{h}}{v_{x_{h}} - v_{x_{r}}}\n",
"\\end{align}\n",
"$$\n",
"\n",
"But this final equation must be true for all three vectors:\n",
"\n",
"$$\n",
"t = \\frac{x_{r} - x_{h}}{v_{x_{h}} - v_{x_{r}}} = \\frac{y_{r} - y_{h}}{v_{y_{h}} - v_{y_{r}}} = \\frac{z_{r} - z_{h}}{v_{z_{h}} - v_{z_{r}}} \n",
"$$\n"
]
},
{
Expand Down

0 comments on commit e5db577

Please sign in to comment.