diff --git a/src/AoC_2023/Dazbo's_Advent_of_Code_2023.ipynb b/src/AoC_2023/Dazbo's_Advent_of_Code_2023.ipynb index b820d62..795d93c 100644 --- a/src/AoC_2023/Dazbo's_Advent_of_Code_2023.ipynb +++ b/src/AoC_2023/Dazbo's_Advent_of_Code_2023.ipynb @@ -8192,7 +8192,7 @@ "\n", "$$\n", "\\begin{align}\n", - "y &= ax^2 + bx + c \\nonumber \\\\\n", + "P(x) &= ax^2 + bx + c \\nonumber \\\\\n", "\\nonumber \\\\\n", "\\text{Therefore:} \\nonumber \\\\\n", "P(0) &= a.(65)^2 + b.(65) + c \\nonumber \\\\\n", @@ -8201,17 +8201,27 @@ "\\end{align}\n", "$$\n", "\n", - "We can rearrange these formulae to come up with a standard set of equations to determine the coefficients $a$, $b$ and $c$:\n", + "We can rearrange these formulae to come up with a standard set of equations to determine the coefficients $a$, $b$ and $c$. (We have three unknowns, so we need three equations to combine.)\n", + "\n", + "To find $c$, we can subtitute 0 for $x$:\n", + "\n", + "$$\n", + "\\begin{align}\n", + "P(0) &= a.(0)^2 + b.(0) + c \\\\\n", + "c &= P(0)\n", + "\\end{align}\n", + "$$\n", + "\n", + "We can then substitute and combine the equations to solve for $b$ and $c$:\n", "\n", "$$\n", "\\begin{align}\n", - "c &= P(0) \\\\\n", "b &= \\frac{(4.P(1) - 3.P(0) - P(2))}{2} \\\\\n", "a &= (P(1) - P(0) - b) \\\\\n", "\\end{align}\n", "$$\n", "\n", - "So this will give us the actual coefficients.\n", + "So this will give us the actual coefficients. Note that these coefficients are only valid for our _real data_ grid, since these coefficients are calculated based on our specific grid sizes and resulting _diamond_ sizes.\n", "\n", "But what value to use for $x$? Here, we want the number of whole tile lengths." ] @@ -8241,8 +8251,7 @@ " b = (4*plot_counts[1] - 3*plot_counts[0] - plot_counts[2]) // 2\n", " a = plot_counts[1] - plot_counts[0] - b\n", " \n", - " x = (steps - grid_size//2) // grid_size\n", - " \n", + " x = (steps - grid_size//2) // grid_size # number of whole tile lengths\n", " return a*x**2 + b*x + c\n", "\n", "ans = solve_quadratic(input_data, plot_counts=[ct[1] for ct in plot_counts], steps=26501365)\n",