Skip to content

Solutions to AoC 2018 problems in modern, type-annotated Python 3.10 🎄

License

Notifications You must be signed in to change notification settings

AxlLind/AdventOfCode2018

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AdventOfCode2018 🐍

Solutions to all 25 AoC 2018 problems in modern, type-annotated Python 3.10!

Finishing this year finally gave me the last stars of Advent of Code, I now have all 350 ⭐ I wanted to finish AoC off in Python to see what it would be like to maybe switch from Rust to Python for AoC 2022. I must say that using Python for AoC is a delight. Things are so simple, while still being really expressive. Unsurprisingly, you skip so much of the boilerplate compared to something like Rust. If I ever want to get a top 100 placing I will probably have to use Python.

I wanted to try the newest version of Python, 3.10, which finally adds pattern matching to Python. It was nice but I failed to find a usecase in these challenges beyond just strictly comparing values. Using such a recent version of Python was a bit annoying though, I could not get pip working and mypy does not support the new syntax yet.

Usage

# run a solution
python3 src/<DAY>.py

# run all solutions, and run static type checking on each
for DAY in src/*.py; do
  echo -e "\nRunning $DAY"
  python3 $DAY
  mypy $DAY
done

Note that at the time of writing mypy does not support 3.10 syntax, which means it fails on a lot of the days.

Other years

endscreen