~tuxpup/aoc_solutions

my solutions for advent of code 2021
catch up on day 18.
missed this in a prior add
day 19 stars (working out of order because 19 is still within 24 hours.)

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~tuxpup/aoc_solutions
read/write
git@git.sr.ht:~tuxpup/aoc_solutions

You can also use your local clone with git send-email.

#Advent Of Code Solutions

This repository started life as my python solutions for 2021's advent of code. My plan was to use this to get my python as idiomatic as possible, but I sometimes changed course depending on the size of my timebox for a given day, a whim, impatience, etc. I also wound up filling in some past years that I either hadn't participated in or solved using C++ under some other login mechanism. I haven't caught the urge to find those old solutions in cold storage and add them here.

For 2022, I'm once again abandoning my ambitions of using a new language and sticking to python, so I'm just expanding this repository to include 2022's solutions.

Any original code here is licensed under the MIT License. I probably won't take the time to vet any dependencies' licenses unless I copy them into this tree. In the unlikely event something from here is worth copying, the burden is on the copying party to check the suitability of the licenses for code that isn't mine.

#2024 Updates

December looks busy this year, but I want to see if I can fit these in. So I'm doing the "boring" thing and going with python again.

Workflow for this year's puzzles, since I clearly didn't leave myself enough detail in this README last time around to quickly figure it out when I sat down cold after the dog woke me at 12:30 AM and decided to stay awake to play:

poetry shell
source .env
export AOC_SESSION
# Year day
aocd 2024 1 --example
# paste the sample data into the day's test case along with the sample answer
# Write notional solution for part1
# run the example data
python -m aoc_2024.day01
# If the test passes, run real data and submit part 1
aoc-geoff run -y 2024 -d 1 -p 1
# If successful, get the part 2 sample answer and set up part2. Once the test passes:
aoc-geoff run -y 2024 -d 1 -p 2

#Usage

After spending some time with rust in 2021, I finally decided to learn to use poetry for my python projects. It behaves a lot like cargo in a good way.

This project uses poetry to manage its virtual environments. Either install it from system repositories or give it its own venv and install it with pip, then put it on your path. Once that's done, from the top level of this repository, run:

bash poetry install

to create a virtual environment with all the necessary libraries.

2022 update: I now like to use pyenv to enable switching between python versions (easily) on a per-project basis. I add poetry to all my pyenv environments when I install them.

If you want to try my solution with your data, the easiest way is to grab your session cookie from a visit to [adventofcode.com] (https://adventofcode.com/) using the inspector in your browser and save it into a top-level file called .env containing the cookie and your preferred data storage location:

dotenv AOC_SESSION=GetYourOwnSessionCookie AOCD_DIR=data

and run using poetry:

bash poetry run aoc-geoff run -y $YEAR -d $DAY

to have the script fetch your input and use it. If you've already got your input saved, you can use

bash poetry run aoc run-geoff -y $YEAR -d $DAY /path/to/saved/input.txt

#Credits

This project uses advent-of-code-ocr, by Benjamin Soyka. It's included in this repository because the version available in PyPi lists an old numpy as a requirement, and I couldn't figure out how to get poetry to consume it from my github fork. It's used under the MIT license, which is included in the package.

It also uses Wim Glenn's excellent advent-of-code-data library to download input and submit solutions more conveniently.