This repository is a basic structure for people interested in solving the Advent of Code puzzles using python3. Use it to test your solutions easier and keep track of your code for future reference. The challenge is held every year between the 1st and 25th of December.
This repository currently includes the example input/output for the puzzles of the years 2021 and 2022, and I´ll be adding more as new challenges get published. Anyway, you can quickly adapt it for any other year.
👉 Check the article I wrote about my experience with the challenge: How To Save Christmas by Coding: Advent of Code
👉 Feel free to check my solutions to each puzzle here.
The Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like. People use them as a speed contest, interview prep, company training, university coursework, practice problems, or to challenge each other.
All the credits about the Puzzles, Code, & Design belong to Eric Wastl (more information on https://adventofcode.com)
I created this repository to:
- 🏗 Provide a basic template structure to solve the Advent of Code puzzles using python3
- 👨💻 Keep track of your progress during the challenge
- 🧪 Test your solutions easier and faster against the example input/output during development
- 💽 Document your solutions for future reference
Feel free to clone/fork this repo and use it as it best fits your needs.
- Clone the repository
- Select a puzzle from the Advent of Code website.
- Copy the example's input into the coresponding
/<YEAR>/example/inputs/<DAY>.txt
file. - Copy the example's output into the corresponding day in the
/<YEAR>/example/outputs.py
file. - Copy the unique input you were given in the corresponding
/<YEAR>/inputs/<DAY>.txt
file. - Code your solution in the corresponding
/<YEAR>/solutions/<DAY>.py
file. - Test your solution by executing the run.py file from the root of the repository with the following command:
$ python3 run.py <YEAR>/<DAY> // e.g: python3 run.py 2024/1
- You'll see the results of testing your solution against the example's input, and if passed, you'll also know the solution for your custom input (the one you need to earn the star ⭐️). Once the Part One of the puzzle is correct, it will also start testing your solution to the Part Two.
(Optional)
- You can also check your progress by getting an overview of your solutions for a specific year by executing the run.py file from the root of the repository with the following command:
$ python3 run.py <YEAR> // e.g: python3 run.py 2024
- You'll see the results of testing all your solutions (Part One and Part Two) against every day example's input, and if it passed or failed, alongisde with a bar showing your progress to motivate you to keep going 💪.
If you want an example of use of this project, check this repository with my solutions to previous years' challenges using this structure.
Just execute the generate_year script with the year you want to generate, which will generate all required files
$ python3 generate_year.py <YEAR>
// e.g: python3 generate_year.py 2023
Here are a couple of ideas to share your appreciation in case this repository was helpful to you in some way:
- Give this repo a star ⭐
- Check my blog 👨💻 https://www.fransandi.com/
- Follow me on LinkedIn and X @fransandi7
- Share your progress 💬 in the Advent of Code with me on X (@fransandi7)
- Send me your suggestions to improve this project 🚀