Skip to content

Files

Latest commit

Jan 12, 2025
8c435e1 · Jan 12, 2025

History

History

python

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Oct 19, 2024
Oct 26, 2024
Oct 21, 2024
Jan 12, 2025
Jan 2, 2025
Oct 23, 2024
Oct 16, 2024
Oct 16, 2024
Oct 29, 2024
Dec 25, 2024
Jan 3, 2025
Jan 12, 2025
Dec 7, 2023
Nov 30, 2022
Dec 10, 2024
Dec 10, 2024
Dec 25, 2023
Oct 13, 2024
Dec 5, 2022

Advent of Code in Python

Solutions to Advent of Code in Python (410⭐):

Day 2017 2018 2019 2020 2021 2022 2023 2024
1 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
2 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
3 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
4 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
5 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
6 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
7 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
8 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
9 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
10 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
11 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
12 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
13 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
14 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
15 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
16 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
17 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
18 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
19 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
20 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
21 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
22 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
23 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
24 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
25 ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐ ⭐⭐
Day 2015 2016
1 ⭐⭐ ⭐⭐
2 ⭐⭐ ⭐⭐
3 ⭐⭐ ⭐⭐
4 ⭐⭐ ⭐⭐
5 ⭐⭐ ⭐⭐
6 ⭐⭐ ⭐⭐
7 ⭐⭐ ⭐⭐
8 ⭐⭐ ⭐⭐
9 ⭐⭐ ⭐⭐
10 ⭐⭐ ⭐⭐
11 ⭐⭐ ⭐⭐
12 ⭐⭐
13 ⭐⭐
14 ⭐⭐
15 ⭐⭐
16 ⭐⭐
17 ⭐⭐
18 ⭐⭐
19 ⭐⭐
20 ⭐⭐
21 ⭐⭐
22 ⭐⭐
23 ⭐⭐
24 ⭐⭐
25 ⭐⭐

Running the Solutions

Navigate to the puzzle folder:

$ cd 2015/01_not_quite_lisp/

Run the full solution by specifying puzzle input:

$ python aoc201501.py input.txt

You can also run on example input:

$ python aoc201501.py example*.txt

It's possible to work with individual parts in the REPL:

>>> import pathlib
>>> import aoc201501
>>> puzzle_input = pathlib.Path("input.txt").read_text(encoding="utf-8").strip()
>>> data = aoc201501.parse(puzzle_input)

>>> aoc201501.part1(data)
232

>>> aoc201501.part2(data)
1783

Bootstrap a Puzzle Solution

Use copier to invoke the Python template and set up files for a new solution:

$ copier copy --trust gh:gahjelle/template-aoc-python .

Answer the questions and allow the hook to download your personal input.

Test a solution

Test individual puzzles from within the puzzle folder:

$ cd 2015/01_not_quite_lisp/
$ pytest -v

You can test (and benchmark) all puzzles for their output by running test_all_puzzles.py:

$ pytest -v test_all_puzzles.py

Finally, you can run all puzzle unit tests by running pytest on the puzzle folders:

$ pytest -v 20*

Adding a Solution to GitHub

Follow these steps after solving a puzzle:

  1. Store the solution to an output file:

    $ python aoc201501.py input.txt > output.py.txt
  2. Run benchmarks and add them to the README:

    $ pytest test_all_puzzles.py -k 2015
    $ cat timings.py.md
  3. Update READMEs across all projects:

    $ cd ..
    $ make