Been a while since I’ve done an advent of code! I’ll probably backfill a few years eventually, but for now, let’s just write some code!
As always, these problems are wonderful to try to solve yourself. If you agree, stop reading now. This post isn’t going anywhere.
If you’d like to see the full form of any particular solution, you can do so on GitHub (including previous years and possibly some I haven’t written up yet): jpverkamp/advent-of-code
Here’s a full list of all of the posts:
Posts in Advent of Code 2021:
- Advent of Code 2021
- AoC 2021 Day 1: Depth Finder
- AoC 2021 Day 2: Submarine Simulator
- AoC 2021 Day 3: Binary Contraption
- AoC 2021 Day 4: His Name Oh
- AoC 2021 Day 5: Linear Avoidinator
- AoC 2021 Day 6: We All Glow Down Here
- AoC 2021 Day 7: Brachyura Aligner
- AoC 2021 Day 8: Seven Segment Demystifier
- AoC 2021 Day 9: Local Minimum Deminifier
- AoC 2021 Day 10: Chunkinator
- AoC 2021 Day 11: Octopus Flashinator
- AoC 2021 Day 12: Submarine Spider
- AoC 2021 Day 13: Foldinator
- AoC 2021 Day 14: Polymerizationinator
- AoC 2021 Day 15: Low Ceiling Simulator
- AoC 2021 Day 16: Depacketinator
- AoC 2021 Day 17: Pew-Pewinator
- AoC 2021 Day 18: Pairs of Pairs
- AoC 2021 Day 19: Point Matchinator
- AoC 2021 Day 20: Enhancinator
- AoC 2021 Day 21: Dicinator
- AoC 2021 Day 22: Cubinator
- AoC 2021 Day 23: Amphipodinator
- AoC 2021 Day 24: Aluinator
- AoC 2021 Day 25: Cucumbinator
And here’s the current testing harness I’m using:
problems = [
[1, '01', 'Sonar Sweep', 'depth-finder.py', {
'part1': 'input.txt',
'part2': 'input.txt 3',
'part2-simple': 'input.txt 3'
}],
...
]
for day, folder, name, file, variants in problems:
print(f'--- Day {day}: {name} ---\n')
for cmd, args in variants.items():
print(f'$ python3 {file} {cmd} {args}')
start = time.perf_counter_ns()
subprocess.check_call(f'python3 {file} {cmd} {args}', shell=True, cwd=folder)
end = time.perf_counter_ns()
print(f'# time {end-start}ns / {(end-start)/1e9:.2f}s\n')
And here are my previous year’s solutions: