Advent of Code: Day 1
I'm going to start off being boring in Python, but it's something! And hopefully I don't make any embarrassingly inefficient choices along the way.
2024 Day 1 Problem: https://adventofcode.com/2024/day/1#part1
Splitting the list into 2:
Sorting the list:
And finally, adding up the distances, using the zip function which I recently discovered:
I might come back and do this in Haskell or some other impractical language... we'll see... but for right now, the ease of Python might just give me a few extra % on my final projects and exams, so I'll have to stick to that.
And that brings me to part 2 :)
Here, it feels like casting the second list to a dict is the obvious choice, the problem's trivial after that.
And then... we do the seemingly arbitrary similarity thing.
And... that's day 1 :)
Answers:
2742123 and 21328497
Comments
Post a Comment