Skip to content

This repository is a basic structure for people interested in solving the Advent of Code puzzles using python. Use it to test your solutions easier and keep track of your code for future reference.

License

Notifications You must be signed in to change notification settings

Fransandi/Advent-of-Code-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎄 Advent of Code 🗓 - Python Structure

License: MIT

Python

Introduction

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.

What is the Advent of Code? 🧩

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)

drawing

About this project

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.

Get Started

  1. Clone the repository
  2. Select a puzzle from the Advent of Code website.
  3. Copy the example's input into the coresponding /<YEAR>/example/inputs/<DAY>.txt file.
  4. Copy the example's output into the corresponding day in the /<YEAR>/example/outputs.py file.
  5. Copy the unique input you were given in the corresponding /<YEAR>/inputs/<DAY>.txt file.
  6. Code your solution in the corresponding /<YEAR>/solutions/<DAY>.py file.
  7. 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
    
  8. 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.

drawing

(Optional)

  1. 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
    
  2. 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 💪.

drawing

If you want an example of use of this project, check this repository with my solutions to previous years' challenges using this structure.


How to add a new year?

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

How to contribute?

Here are a couple of ideas to share your appreciation in case this repository was helpful to you in some way:

About

This repository is a basic structure for people interested in solving the Advent of Code puzzles using python. Use it to test your solutions easier and keep track of your code for future reference.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages