advent_of_code_2021

My attempts to work through the 2021 Advent of Code problems.
git clone https://git.eamoncaddigan.net/advent_of_code_2021.git
Log | Files | Refs | README | LICENSE

commit 1382a599ad70cc4124cc5c7946c6ff39d5bd0556
parent 42fc3fccad6918c9bc395c900d4e6e16d9824917
Author: Eamon Caddigan <eamon.caddigan@gmail.com>
Date:   Tue,  7 Dec 2021 17:32:45 -0500

Clarifying the comments a bit

Diffstat:
Mday07_part1.py | 22++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/day07_part1.py b/day07_part1.py @@ -6,16 +6,18 @@ minimize fuel""" # end_position))? Let's do a quick and dirty proof in the Advent of Code # universe. # Suppose that we've already moved all the crab submarines to the median -# position, x_m, but there's actually a better position that's greater than -# x_m, which we'll call x_o. If we had moved the submarines to position x_o -# instead of x_m, all of the subs with positions less than or equal to x_m -# would spend the same amount of additional fuel, and all of the subs with -# positions greater than or equal to x_o would save that same amount of fuel -# (we can forget about the subs between x_m and x_o for now). However, by the -# definition of the median, the majority of subs have positions less than or -# equal to x_m, which means moving to x_o will necessarily cost the crab sub -# fleet more fuel than it saves. The same logic applies to an x_o less than -# x_m, so we have proven by contradition that x_m must be the best position. +# position, x_m, but there's actually a better position--that's greater than +# x_m--which we'll call x_o. If we had moved the submarines to position x_o +# instead of x_m, the subs with positions less than or equal to x_m would each +# spend the same amount of additional fuel to reach x_o, while the subs with +# positions greater than x_o would each save that same amount of fuel (no need +# to worry about any subs between x_m and x_o for now). +# However, by the definition of the median, the majority of subs have +# positions less than or equal to x_m, which means moving to x_o will +# necessarily cost the crab sub fleet more fuel than it saves (i.e., there are +# more subs spending extra fuel than there are saving fuel). Since the same +# logic applies to an x_o less than x_m, we have shown by contradition that x_m +# must be the best position. from utils import get_puzzle_input, convert_int_line_to_series