You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"Another year, another set of puzzles! This time, we are 'not doing christmas'; Eric Wastl has torn up the [AoC Bingo card](https://www.reddit.com/r/adventofcode/comments/k3q7tr/my_advent_of_code_2020_bingo_card_fun_little_side/) and decided to send us to a tropical island instead. :-P\n",
31
12
"\n",
32
-
"As always, we start with a warm-up. Rather than iterate over all combinations ($O(n^2)$), put the numbers in a set, loop over the set for the first number, and see if `2020 - first` is a member of the set. That gives us a $O(n)$ runtime!"
33
-
],
34
-
"cell_type": "markdown",
35
-
"metadata": {}
13
+
"As always, we start with a warm-up. Rather than iterate over all combinations ($O(n^2)$), put the numbers in a set, loop over the set for the first number, and see if `2020 - first` is a member of the set. That gives us a $O(n)$ runtime!\n"
"To find the third coin, just pop one of the values of the set of coins, run the first puzzle solution to see if there is a combination that sums to `2020 - selected`, and continue until we found a combination. That's an $O(N^2)$ solution:\n"
"I like to use a dataclass for parsing tasks like these. A single regex to read out each line, and methods on the class to implement the password rule checks."
31
-
],
32
-
"cell_type": "markdown",
33
-
"metadata": {}
11
+
"I like to use a dataclass for parsing tasks like these. A single regex to read out each line, and methods on the class to implement the password rule checks.\n"
0 commit comments