Skip to content

Commit

Permalink
Day 21 docs done
Browse files Browse the repository at this point in the history
  • Loading branch information
derailed-dash committed Dec 23, 2023
1 parent 582e012 commit 380bef7
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/AoC_2023/Dazbo's_Advent_of_Code_2023.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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."
]
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 380bef7

Please sign in to comment.