AdventOfCode is a yearly event for which a new, two-part, coding challenge is released each day of December until the 25th.
This year I attempted the challenge in Python, with the intension of producing as elegant and readable solutions as I can.
Below is a summary of my solutions to the problems. In the ReadMe.md file for each day you will find the problems themselves, along with more thorough notes on my solutions.
Some python solutions will import modules from my aoc_tools package, you will need to install this using:
pip install aoc-tools-dannyboywoop
| Problem | Keywords | Brute-force time complexity | My time complexity | Part 1 time (ms) | Part 2 time (ms) | Total time (ms) |
|---|---|---|---|---|---|---|
| Day_01 | Recursion, HashSets. | Part 1 - O(n2) Part 2 - O(nm) |
Part 1 - O(n) Part2 - O(nm-1) |
5 | 2 | 10 |
| Day_02 | String parsing. | Part 1 - O(n) Part 2 - O(n) |
Part 1 - O(n) Part 2 - O(n) |
6 | 2 | 14 |
| Day_03 | Arrays. | Part 1 - O(n) Part 2 - O(n) |
Part 1 - O(n) Part 2 - O(n) |
5 | 2 | 10 |
| Day_04 | String parsing, regex. | Part 1 - O(n) Part 2 - O(n) |
Part 1 - O(n) Part 2 - O(n) |
6 | 6 | 18 |
| Day_05 | Binary. | Part 1 - O(n) Part 2 - O(n) |
Part 1 - O(n) Part 2 - O(n) |
2 | 1 | 9 |
| Day_06 | HashSets, Set algebra. | Part 1 - O(n2) Part 2 - O(n2) |
Part 1 - O(n) Part 2 - O(n) |
N/A | N/A | 12 |
| Day_07 | Tree search, Recursion, Memoisation, HashMaps. | Part 1 - O(2n) Part 2 - O(2n) |
Part 1 - O(n) Part 2 - O(n) |
6 | 2 | 15 |
| Day_08 | Interpreter, Halting, HashSets. | Part 1 - O(n2) Part 2 - O(n3) |
Part 1 - O(n) Part 2 - O(n2) |
5 | 11 | 20 |
| Day_09 | HashSets. | Part 1 - O(n3) Part 2 - O(n3) |
Part 1 - O(n2) Part 2 - O(n) |
5 | 2 | 10 |
| Day_10 | 4 | 2 | 10 | |||
| Day_11 | 484 | 645 | 1142 | |||
| Day_12 | 7 | 8 | 23 | |||
| Day_13 | 6 | 4 | 14 | |||
| Day_14 | 9 | 152 | 164 | |||
| Day_15 | 1 | 13250 | 13255 | |||
| Day_16 | 5 | 6 | 16 | |||
| Day_17 | 47 | 624 | 675 | |||
| Day_18 | 10 | 15 | 31 | |||
| Day_19 | 45 | 97 | 147 | |||
| Day_20 | 7 | 40 | 72 | |||
| Day_21 | 5 | 2 | 12 | |||
| Day_22 | 5 | 3697 | 3706 | |||
| Day_23 | <1 | 34619 | 34625 | |||
| Day_24 | 7 | 805 | 822 | |||
| Day_25 | 2726 | N/A | 2727 |
Total time to run all solutions: 57.56 seconds.
Notes:
- The total times are often greater than the sum of the two parts. This is because it also includes the time taken to parse the input.
- The values for brute-force time complexity almost always assume that python lists have been used as the primary data container (as this often seems to be the case for beginners approaching these problems).