advent of code 2020 day 2
easy day, so of course i chose to overcomplicate it https://github.com/undergroundmonorail/advent-of-code-2020/tree/main/day%202
like come on holly what the fuck is this
print(sum((is_valid(*(re.findall(r'(\d+)-(\d+) (.): (.+)', line)[0])) for line in f)))
clean it up
advent of code 2020 day 3
did it first thing after waking up so it's a weird flavour of "too clever for its own good"
https://github.com/undergroundmonorail/advent-of-code-2020/tree/main/day%203
advent of code 2020 day 4
data validation problems are
- easy
- not fun
https://github.com/undergroundmonorail/advent-of-code-2020/tree/main/day%204
advent of code 2020 day 5
rank 337 for part 1 and rank 398 for part 2
and i had to debug some shit i really should have gotten on the first go, but i don't think it would have been enough
oh well
https://github.com/undergroundmonorail/advent-of-code-2020/tree/main/day%205
advent of code 2020 day 5
i did a "real" pass at day 5, since my first attempt was speedrunning it to try to get on the leaderboards. i still have that code saved in a directory but i don't think that you should write code like that
that said, i still don't really get what the clever way to do part 2 would be. it feels like there should be something but honestly i have no idea
https://github.com/undergroundmonorail/advent-of-code-2020/tree/main/day%205
explicit spoilers, advent of code 2020 day 5
pretty embarrassed with myself for thinking for like six hours "the seat codes are related to binary, i can do something binary-esque to decode them" and then didn't realize until after implementing something that worked that it's literally just binary. F and L are 0, B and R are 1
i still used reduce(lambda x, y: x*2 + y, my_iterable)
to actually convert to decimal though. i considered just replacing the characters in the string with 0s and 1s and doing int(s, 2)
, but i chose not to to keep the code lazy. in theory it should handle arbitrarily large airplanes without having to construct any huge strings, i think
advent of code 2020 day 5
god i'm looking at the code that i wrote as quickly as possible and for part 2 i literally do for i in range(999999):
, check if i
is my id, and if it is i print and break
my code that i wrote without trying to go as fast as possible is only barely nicer
surely there's a better way