A list of all my solutions to advent of code through the years. The first year I completed all of the problems was 2022. I am working on building my solution bank for the years prior.
I am currently working through 2018, attempting learn Lean.
I use the advent-of-code-data library that is on pip. I have also made myself some helper functions, these are start_day.py and copier.py. start_day.py gets the data from the website and creates an input.txt file for me to get the data and a pre-written starter piece of code that allows me to both test and submit my code. copier.py allows me to streamline the writing of my solution to the second part, whilst keeping my part 1 solution. It copies all the important sections of code from my first solution whilst removing the parts no longer necessary.
- Solutions in other languages (Haskell, C, Rust)
- Run-time tester
- Time taken to solve from getting input (instad of 5 am)
Clone the repository then install the advent-of-code-data library via pip, using python -m pip install advent-of-code-data. Then install the local library copier using python -m pip install -e copier.
Run the command python start_day.py -y=<year> -d=<day>, where year and day will default to the current day/year if not inputted. This will then create the corresponding folder and files to solve the days problem. It will also make a copy of the input in input.txt and create a blank test.txt file to input test data into.
To run your solution you can run the command python <year>/<day>/solution.py, using arguments -T=<test_answer> to run from test file, -R to run from the input file and submit and --log=<log_level> to set the logging level of the code.
On success a second file will be created called solution2.py, this has all your code copied into a new file so you can keep your old solution with minimal effort. This is called in a similar way to the first solution just changing solution.py to solution2.py.
When the copier fails, you can run it manually via the command python copier/copier.py -y=<year> -d=<day> and it will create the solution2.py by itself, note that if the file already exists you will have to delete it in order for it to create a new one.