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
advent of code 2020 day 6
this works on the example set but not on my data set and i'm furious about it
def num_yes(answers):
first, *rest = answers.split('\n')
return sum((all((c in a for a in rest)) for c in first))
def main():
with open('input.txt') as f:
print(sum(map(num_yes, f.read().split('\n\n'))))
if __name__ == '__main__':
main()
advent of code 2020 day 6
with that out of the way here's my code
easy day other than having to fight with the trailing newline for part 2
https://github.com/undergroundmonorail/advent-of-code-2020/tree/main/day%206
advent of code 2020 day 7
yeah i got it
part 2 was actually much easier than part 1 tbh
today was the day of off by one errors. in both parts i forgot to not count the shiny gold bag itself
https://github.com/undergroundmonorail/advent-of-code-2020/tree/main/day%207
advent of code 2020 day 8
day 8 was pretty easy
https://github.com/undergroundmonorail/advent-of-code-2020/tree/main/day%208
you can tell i like functional stuff more than the average python user because i had to write this:
def first_true(it):
for e in it:
if e:
return e
i thought i could use any()
for that, since it's basically just applying or
over an iterable and or
short circuits when it gets a truthy value, but any()
returns a literal True
or False
while i actually needed the truthy object
advent of code 2020 day 9
catching up on aoc
day 9 solutions kinda suck but here they are. they do work i just feel like they're very naive
https://github.com/undergroundmonorail/advent-of-code-2020/tree/main/day%209
advent of code 2020 day 10
so this was a weird one
i read part 1 over and over again because i was like "i must be missing something, there's no problem here. where is the programming challenge" but no it's just... nothing. it kinda tries to confuse you with stuff like your adapters being rated for a difference of 3 jolts but since you know every adapter has to be used, that's completely irrelevant to you. the jolts can never go down so you just sort the list.
i still managed to overcomplicate my part 1 solution but you could write it in a much simpler way. i just chose not to
my part 1 and 2 answers are almost nothing alike
https://github.com/undergroundmonorail/advent-of-code-2020/tree/main/day%2010
re: advent of code 2020 day 10
@monorail it's a challenge if you do it recursively
re: advent of code 2020 day 10
@monorail the sub is full of "waiting for part 2 to finish running" memes