advent of code 2020 

monorail@DESKTOP-T7R40II:/mnt/d/Documents/advent_of_code_2020/day 1$ diff part1.py part2.py
10c10
< for pair in itertools.combinations(entries, 2):
---
> for group in itertools.combinations(entries, 3):

only had to change one line, and honestly only HAD to change one character

advent of code 2020 

ah fuck i actually forgot to include the other lines with pair in it being changed but whatever

advent of code 2020 day 2 

easy day, so of course i chose to overcomplicate it github.com/undergroundmonorail

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 2 

it just seems so WASTEFUL to have explicit loops and a temp variable so store the number of valid passwords or whatever

advent of code 2020 day 2 

advent of code encourages insecure password database practices

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"

github.com/undergroundmonorail

advent of code 2020 day 5 

going to try to do day 5 as fast as possible, maybe win points

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

github.com/undergroundmonorail

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

github.com/undergroundmonorail

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 

bah, i'm pretty sure this code works but i typed the answer wrong into the page and now i have to wait a minute before i can type it correctly

advent of code 2020 day 6 

okay now i'm on part 2 and my code actually is wrong

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

github.com/undergroundmonorail

advent of code 2020 day 6 

also i feel like i fairly rarely get to use first, *rest = my_iterable so that's exciting

advent of code 2020 day 6 

not that it was completely necessary, i could have used answers.split('\n')[0] instead of first and answers.split('\n')[1:] instead of rest. or even just checked the answers in the first one against itself. but this is a little more clear

advent of code 2020 day 7 

i feel like this code should work and i don't know why it isn't

advent of code 2020 day 7 

it's giving me a reasonable answer but it's wrong, which sucks

advent of code 2020 day 7 

the more i look at this code the more i convince myself that it's right, which is a shame because it's not

advent of code 2020 day 7 

oh fuck me i think i figured it out

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

github.com/undergroundmonorail

advent of code 2020 day 8 

day 8 was pretty easy

github.com/undergroundmonorail

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 8 

everything in the iterable that function gets is a number, most of which are 0 and one of which is the solution to the problem

so i could have just used sum() but i didn't want to keep calculating when i already had the answer

advent of code 2020 day 8 

okay i just tried it with sum() and the difference in execution time is completely indistinguishable so maybe it was a waste of time

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

github.com/undergroundmonorail

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

github.com/undergroundmonorail

Follow

re: advent of code 2020 day 10 

@monorail it's a challenge if you do it recursively

· · Web · 1 · 0 · 1

re: advent of code 2020 day 10 

@monorail the sub is full of "waiting for part 2 to finish running" memes

re: advent of code 2020 day 10 

@noiob yeah part 2 is a genuine programming challenge

part 1 is a "don't get confused while reading the spec" challenge

re: advent of code 2020 day 10 

@monorail oh yeah the spec is prolly the biggest challenge for me this year

Sign in to participate in the conversation
Awoo Space

Awoo.space is a Mastodon instance where members can rely on a team of moderators to help resolve conflict, and limits federation with other instances using a specific access list to minimize abuse.

While mature content is allowed here, we strongly believe in being able to choose to engage with content on your own terms, so please make sure to put mature and potentially sensitive content behind the CW feature with enough description that people know what it's about.

Before signing up, please read our community guidelines. While it's a very broad swath of topics it covers, please do your best! We believe that as long as you're putting forth genuine effort to limit harm you might cause – even if you haven't read the document – you'll be okay!