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 

fuckin rip, not even close

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

Follow

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

Web 1 0 1

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()

caps, advent of code 2020 day 6 

TRAILING NEWLINE

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

advent of code 2020 day 10 

in part 2 i didn't bother to stick around and see if a naive recursive solution would ever finish. i let it go for a couple seconds to see and after that it wouldn't even respond to ^C, i had to close the whole powershell window

luckily it runs instantly when you just put the functools.cache decorator on the naive recursive solution

Show newer

advent of code 2020 day 6 

@monorail oh mood

caps, advent of code 2020 day 6 

advent of code 2020 day 7 

@monorail huh

maybe i should do this advent of code thing idk

re: advent of code 2020 day 7 

@monorail well then i'll give it a go i guess

This is intentionally obnoxious, I mean no harm, re: advent of code 2020 day 7 

@monorail Today is the 8th though

re: advent of code 2020 day 9 

@monorail I mean they're very simple

I used a library and I'm pretty sure that was very much not needed

re: advent of code 2020 day 9 

re: advent of code 2020 day 10 

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

Show newer
Show newer

re: advent of code 2020 day 7 

@monorail yeah i had a whole bunch of off-by-ones in my pt2 solution too. complained about it in my friends irc channel, and apparently saved someone from the same fate, heh

caps, advent of code 2020 day 6 

@monorail I feel this

advent of code 2020 day 5 

@monorail my day 5 solution seems very silly now tho lol

re: advent of code 2020 day 5 

@monorail i do it basically just how they "explain" it, starting with a region of 0-127 and cutting the region in half with each character

sets make part 2 very easy tho

re: advent of code 2020 day 5 

@skelly oh yeah i did it that way for my first solution

re: advent of code 2020 day 5 

@monorail for part 2 i just generate a set of every number from 0 - (max id) and then subtract that list from the set of id's

so that'll give a bunch at the beginning (before our id's actually start) and then the last item in the set will be the missing id

re: advent of code 2020 day 5 

@monorail instead of delete and redrafting AGAIN just pretend anywhere i accidentially say "list" i mean "set"

re: advent of code 2020 day 5 

@skelly i saw people say another way you could do it was find the sum from min_id to max_id (which doesn't have to be done by summing it all up in a loop, there's a formula) and then subtracting out the ids you actually have, which is a similar idea

re: advent of code 2020 day 5 

Sign in to participate in the conversation
glaceon.social

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!