Skip to content

Latest commit

 

History

History

python

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Advent of Code: Python

2024 Solutions
2023 Solutions
2022 Solutions

Runner

I've written a basic runner (run.py) which allows you to conveniently run puzzles from a CLI. If you are using my devcontainer, the runner can also be run using the aoc command rather than calling the Python script directly. See the help text below for usage:

usage: run.py -y YEAR -d DAY [-p PART] [-r | -t | -i | -o | -s] [-f] [-h]

CLI Arguments

  • -y / --year and -d / --day: These are required arguments that determine what .py file is imported as a module. All other arguments are optional.

  • -p / --part: Allows you select only a specific part to run. By default, both parts will run if found.

  • -r / --run: This is the default option when no other option is selected. This will download your puzzle input and pass it to your solver (imported from your solution as part1 or part2 taking a str input and returning Any) to be run.

  • -t / --test: Imports constants defined in your solution named PART1_TESTS and PART2_TESTS if found, each being a list[tuple[str, Any]], with the tuples being the test inputs and expected outputs. These will be passed to your solver to be run.

  • -i / --input: Downloads your puzzle input and prints it.

  • -o / --open: Opens the puzzle URL in your browser.

  • -s / --start: Starts a new puzzle by copying template.py, then opening the new file (if run inside VSCode), opening the puzzle page in the browser, and printing the puzzle input.

  • -f / --fast: By default, when the solver is run it will repeatedly run for 1 second and print the median execution time. With the -f option, it will only run once.

Note

The runner expects the environment variable AOC_SESSION to be set in order to download your input. See wimglenn/advent-of-code-wim#1 for more information.