This repository contains solutions for the Advent of Code challenges.
To get started with this project, you need to have uv installed.
With uv installed you can use make sync to create and synchronize a virtual environment with all the dependencies needed.
If you want to use the aoc commands below such as looking at a leaderboard or downloading puzzle inputs you'll need a session token from adventofcode.com. Visit the website and login, then use devtools to inspect your requests and copy your session token. It'll be in the headers of your request as a cookie called session. This needs to be put into an environment variable called AOC_SESSION which is easiest to do by creating a .env file which has the contents:
AOC_SESSION=your_session_tokenTo get started with I used make setup to install tools like ipython that I use for solving problems.
To prepare for a new puzzle I follow this process:
- run
advent create <day>where<day>is the current puzzle number to solve. This uses_template.pyto create a file that's ready for development with a few utilities like theprfunction which makes copying answers easy. - Open a terminal and get ready with
advent download <day>, you'll be running this as soon as the puzzle drops - Open another terminal with
ipythonwhich you'll use for development. I mostly used the%run dayXX.pymagic function to allow me to run scripts quickly but still have an interactive shell. By keeping code at the module-level after you use run you have access to all variables for further development. As you finish logic you can pull it out into a function for readability.
The advent package provides several CLI commands to help you manage and run your solutions. Below are the available commands:
-
advent create <day>: Initialize the solution for a specific day.advent create 1
-
advent download <day>: Download the puzzle input to thedata/directory for use in your scriptadvent download 1
-
advent download-all: Download all currently released puzzle inputsadvent download-all
-
advent lb --day <day>: print the top of the leaderboard for the given day filter (optional), shows actual submission times instead of just starsadvent lb --day 1
Use advent --help for more information as all commands are documented and be sure to checkout all of the solution utilities like aoc/grid.py