Yes, I do "".join(). Python is not always beautiful. I began reusing part 1 for part 2, until I realised you cannot reuse the Counter.most_common, and you need the actual values to be able to se equal occourences. I probably lost 5-15 minutes just to dribble with 3 levels of nested objects. In GMT+1 before coffee, that cost me. Part 2 was way uglier before some well motivated refactoring. Since all tests and expected output were in place, refactoring was easy. |
||
|---|---|---|
| .. | ||
| solutions | ||
| tests | ||
| .gitignore | ||
| .python-version | ||
| aoc.py | ||
| README.md | ||
Advent of Code 2021
Solutions for #aoc2020 in Python 3 (3.8+).
Help scripts
Solve all puzzles:
python aoc.py
To bootstrap a new puzzle (creates inputs/<day_no>.txt, solutions/day_<day_no>.py och
tests/test_day_<day_no>.py):
python aoc.py <dag_no> "<puzzle_name>"
Manually copy the puzzle input from https://adventofcode.com and paste it in inputs/<day_no>.txt
to start coding.
Solve separate puzzle (replace XX with the puzzle number):
python -m solutions.day_XX
Run tests (replace XX with the puzzle number):
python -m unittest --locals -v
# or, if `pytest` is preferred:
pytest