デイヴ Profile picture
Pinch of doubt, dash of empathy, heaps of sarcasm. Dislikes: cocksure stupidity & bad statistics. 🌍 Climate stuff 👉 @TenkoAI 🥖 👉 @deivudesu_fr he/him/yo
Dec 5, 2020 48 tweets 22 min read
For this year's #AdventOfCode, my goal is to get each day's solution in the most readable format that will fit in a tweet. Striving for a compromise between conciseness and (subjective) elegance… 🧵 #AdventOfCode Day 1 (in Python 🐍):
# (relies on a few input assumptions)

data = [int(i) for i in open('01')]

print("Part 1:",
next(x*y for x in data for y in data if x+y == 2020))

print("Part 2:",
next(x*y*z for x in data for y in data for z in data if x+y+z == 2020))