#Advent of Code 2021
1 messages · Page 1 of 1 (latest)
@fluid remnant what's ur part 1/part2 times
00:04:16 2 21 00:06:32 1 22 43
thats for global
Im actually
so hype rn
wow
that delta tho
I had an off-by-1 due to me misreading the question on part 2
Lol 2 of my friends had that
Luckily I didn't
How come arson did it faster than abex but got a lower rank?
w += v[i] - v[i-windowsize+1] 🤡
I believe @fathom grotto or someone finished part 2 before I did, and got the 21 points, so I only got 20 for part 2. I got 22 points for part 1 because I finished first
but if you sort by global leaderboard
😎 😎
It sure woke me up, if nothing else.
factss
Mine was shit because its 5am and I did not wake up properly in time coping I know
Well done on your rank 93rd though arson!
yeah, I had to double check my math to make sure I didn't have an OBOE
Thank you! Unfortunately it will not help me get to sleep any faster lol
yea exactly
got distracted and missed the start
fiddling with the bounds to make it not error cause me to make that mistake
1 00:52:16 9788 0 00:54:34 8405 0
nice part 2 timing though
way faster than me:)
I had to think a moment about where to start counting on part 2, especially switching back to a 0-index language
you don't actually need the sum to do part 2 either lol
yep
I was writing the sum code and thinking
"I'm just adding sum to one side and then subtracting it from the other side"
yeah i'm optimizing now, i just did it quickly
you're just comparing i with i-1 and then with i-3
lesson learned tho, instead of inputs name ins or smth
ok i got it to one line. lol
you doing code golf this year?
making code look nice
Whats this lol
I don't really enjoy the "least number of bytes" approach or whatever
yea
I almost missed the start. Noticed when the task was already up.
I actually didn't notice this 😅 Did it the quick and dumb way.
I love that for pt2 it just boils down to a > d
I didn't realise until I made my solutions in unreal blueprints
Yup
now do it with combinators
part 2 in Rust:
||nums.windows(4).filter(|w| w[3] > w[0]).count()||
optimizes nicely: https://godbolt.org/z/Kv3vYTP76
Yeah that’s essentially my python solution
C. ||replace 3 with 1 to get the solution for part 1 and make the optimizer think you're on drugs||
that's a very C solution
K&R would be proud I'm sure
python
||(ilen(True for w in sliding_window(depths, x) if w[-1] > w[0]) for x in (2, 4))||
Eww, ligatures
Lol y'alls solutions are so elegant
Here's an inelegant one for you:||lisp (let ((count 0) prev1 prev2 prev3 next) (with-open-file (input "input") (setq prev1 (read input) prev2 (read input) prev3 (read input)) (loop (setq next (read input nil)) (unless next (return)) (when (> (+ prev2 prev3 next) (+ prev1 prev2 prev3)) (incf count)) (shiftf prev1 prev2 prev3 next) ) ) (print count) )||
(spoilered code block still being broken)
Is this time based on time after the problem is released, or time after opening the AoC or what?
Because the first problem definitely didn't take me 10 minutes lol
time since release (0500)
if you don't start on time, you just gotta flex your time between parts 1 and 2 🙂
Ah ok. I didn't start until probably 5-8 after. Dang I could have had a pretty decent score :p (err rank, not score)
yeah. the first few are usually really hard to get good leaderboard ranks on, because they're so easy
how hard do the problems get?
my best placement in 2020 was on problem 21
go look at previous years and see!
day 20 was a doozy
Oh i see what's going on with p21, part 1 at least doesn't look too bad
I'm not entirely sure how I'd structure it, it's a bit like a relational database problem lol
oh man 20, that's not fun at all lol
I had so many dumb bugs in my day 20 last year. it took forever to make work
yeah, i made a loooot of mistakes
but i got almost the same placement on each, so i wasn't dumber than anyone else:
20 00:42:20 923 0 03:40:25 1082 0
I did part1 fast enough, but it wasn't right enough to do part 2 without fixing the bugs so I went to bed
yeah, i'm on the west coast so it was only 12:40 when i finished
guessing a lot of people went to bed though
hm, last year's leaderboard: https://adventofcode.com/2020/leaderboard/private/view/991696
T-1. I can already feel the impact aoc is having on my sleep schedule lol
you can sleep next year :P
2 00:03:10 1157 0 00:04:58 866 0
meh
i don't understand how people even read the problem fast enough to do it
I got the right answer but negative and lost a minute :(
didn't try on the test input first? 😦
gotta go fast
I spent > 2 minutes because I made up go down and down also go down
would've gotten it right if I haven't been a dumbass
lol, gotta check those signs
u read from the bottom up@chilly heart, then the info is most direct (specific?) to least direct
I lost a couple minutes trying to figure out how captures work in python before remembering I could just split the string on the space ¯_(ツ)_/¯
yeah, fair enough
I hope the tasks don't take five days to get nontrivial
they usually do
I suspect they don't. I guessed what the problem would be from the first few lines, although I have read it completely anyway in case of something unexpected.
I also forgot that rust's split returns an iterator and not a vec which took a second longer than it should have
I need the five days to make my friends who are bad at coding feel like they didn't die on day 3 heh
2020d6 was the best for me:
6 01:20:20 11100 0 01:20:34 9571 0
14 seconds for part 2! lol
I mean you literally just have to change one operator
||d25p2 is even faster if you know what to expect||
just looking at my part1-2 deltas, 2020d10 was the first one that took me >20 minutes for part 2
2020d20 was a pain, I eventually got fed up and had to go to sleep
I finished d21 before I finished that
yeah, i got pretty crazy with that one
2020d20 was the one that took me most of the day to do (12 hours). I think, I got tired of coding, too, and had breaks throughout it.
my solution has 9 methods. it has typealiases!
it doesn't have any classes though. typealiases are close i guess
if rotate == 0:
r = [x for x in t]
elif rotate == 1:
r = [list(reversed(x)) for x in z]
elif rotate == 2:
r = [list(reversed(x)) for x in reversed(t)]
elif rotate == 3:
r = [x for x in reversed(z)]
part of my 2020d20 solution. lol
i'm kinda impressed with how ridiculous my solution is
i could do it WAY better if i spent some time on it
mine had this clusterfuck in it https://github.com/abextm/advent-of-code/blob/master/20/src/day20.rs#L237-L253
i actually think it might be nice-ish to do in a vector/matrix oriented language
someone can probably do it in like 20 lines of matlab
or maybe julia nowadays, but yeah
probably yeah
day 18 was a good one too. i did it first the hard way, then the silly way (replace operators in the string with ones that have the precedence you want, parse to AST, change the operators back in the AST, then eval)
I'm so mad, I could have done part 1 in 5 minutes but I fooked up my variable naming so got confused and so got it wrong twice causing a 5 min timeout, my delta for p2 was 2:27 though so I'm happy about that
Mine is operating on edges, with a tiny inline lookup for rotation. E.g. lisp (setq bottom-edge (aref (car (gethash index tiles)) (if flipped (case rotated (0 1) (1 2) (2 3) (3 0)) (case rotated (0 2) (1 3) (2 0) (3 1)) )))
nice one
for 18 I just made a tokenizer and then eval'd it with a shunting yard
2020d20p2 is also probably my most commented AoC code ever.
mine has no comments. looking at it now is making my head hurt
same here, but re-reading those same comments a year later and they only make 50% sense 😹
Mine all make sense to me. Remind me how exactly it works, even.
meanwhile mine is itertools-heavy code without comments
i've trolled myself, basically
TFW your language has a built-in tokenizer 😎
(that's what read actually is in Lisp, same thing it uses to read your code)
Makes some tasks easier, like today's one. I literally just read the action and argument without having to do any input recognition.
God forbid there being any commas in the input though.
(although I guess I could bypass it with a custom readtable, I don't use them nearly as often as I could have)
My usual response to a comma-separated list is reading it all as a string, replacing all commas with spaces, wrapping it in parentheses and reading a list normally from the resulting string.
The pattern recognition part is a bunch of copypaste though (for all rotations) 🤔
For some reason I didn't make it into a closure.
Yeah, running it through compare, the only difference is the rotated pattern variant.
yeah
for step 1, I just counted the numbers of 1 in each column and just chose 1 if it was more than half the # of lines
that approach does... not work in p2
the real question is
how do I generalize o2 and co2 finding
cause it's one conditional
I just put it in a method passed a bool for which one it was
and xored it in the condition
got caught up on the terminating condition for the second part of p2
with the CO2 scrubber, a single element would remove itself (since it's the most common value) and I didn't check for when there was only 1 number left
I took way too long with this task. Needed to look up so many things. Shows how poorly I know Common Lisp stdlib, I guess.
I tried putting the story into a comment and having Copilot write the solution
It worked reasonably well in that copilot gained a lot of context, but not so much in solution correctness
And p1 turned out completely different from p2 the way I approached it.
I did this.
I actually think of the easiest ways might be a shell script that greps in a loop
Would make a ton of files, but lol
Yeah basically. Haha
Only 12 files, no? For the number of digits.
But you don't need the other part.
Right, yeah. Haha
I discovered this lovely thing called Counter from collections and simplified my code a LOT
if A does not = B, remove U235
def day3a(inparr,mode):
fun = [float.__lt__,float.__ge__]```
fun!
Part 2 was quite similar to part 1 for me, pretty much just an added step for the bit criteria
there's a squid attached to the sub!
it probably just wants to play bingo
like those crabs that hopped on the raft to play War last year
This one was pretty easy, especially part 2. Took a long time to code though.
There was only one crab, IIRC, and it was small.
especially part 2
(although I have still managed to confuse myself as to ||what single condition check I need to change|| and took an entire two minutes to do it)
inb4 Recursive Bingo 
I liked the rule in Recursive War where if you reached a stalemate the tie went to you and not the crab
no wonder he got angry and challenged you to a different game
Kidding, right? Took me 30 minutes to just parse the boards lol
Took me 20 minutes for that, but that is hardly a complicated task.
it was just a bit tedious
Exactly.
(well, you can always reformat your input into a data structure init if you want to go faster)
Fucking finally, done pt1
I spent about 20 minutes debugging while thinking the winning board points are the sum of the winning column/row multiplied by the current number 
really need to read slower next time
hm, can't spoiler a three tick code block, huh
tried to put more effort into applying list comprehension
Damn that's a smart way of doing it
i know we're not doing code review, but
for i in range(len(boards)):
board = boards[i]
can be written as
for i, board in enumerate(boards):
which, incidentally, is a line in my (otherwise significantly different) solution
yes review my code please, because TIL about enumerate
it's super useful and lots of people don't know about it
it's like I'm missing on how to do for k,v in pairs() but in py
for k, v in somedict.items():
oh. right, i can do that too
I did some stuff with set math
and yeah, I'm aware there are some optimizations i should make. but it's a totally different approach from yours 🙂
and yes, my familiarity with list comprehensions is such that i did that instead of remembering how to index with steps 🤦
ooh yeah getting the unmarked numbers by subtracting the marked ones, that's great
x for i, x in enumerate(board) if i % 5 == n this! I forgot how to do that conditional
ahaha
my mind laser-focused on the word WHERE
yes, the not stupid way to write that is simpler:
set(board[n:-1:5])
i was just brainfarting at the time
well, uh, I'm learning here 
but yeah, with list comprehensions you can basically turn any python script into a single line
it'll be incomprehensible (list incomprehensions, amirite?!), but it's entertaining
hm, i should figure out how spoiler tags work
can't do spoilers with triple-backtick, so it's a bit subpar for posting code
Please note that text marked as Spoiler within code blocks will not be hidden.
yeah, i just read the documentation to find that out :P
attaching files works because they're collapsed, so as long as the first few lines aren't interesting...
local Debug = true
if debug == true then
print("Debug Screen")
end
A lot of step-by-step solutions (and a lot of Python solutions 🤔 ). I went with something simpler, if perhaps less optimal.
too bad discord can't display that directly lol
It works as a spoiler 😛
which part? I'm curious now 
Using OOP and not brute forcing with quintuple nested for loop
So, I guess it's actually the lack of being a fool that made me exclaim that
wait, five for loops?
in case anyone's interested (spoilers):
https://github.com/tzwaan/advent-of-code/tree/master/2021/day4
walrus!
walrus?
:=
At least it isn't as bad as my 2020 day 17 solution that went up to 12 nested for loops
have you heard about this thing called a function?
It was funny
def lifeRound(grid):
newGrid = {}
for xAxis in range(min(x[0] for x in grid.keys()) - 1, max(x[0] for x in grid.keys()) + 2):
for yAxis in range(min(y[1] for y in grid.keys()) - 1, max(y[1] for y in grid.keys()) + 2):
for zAxis in range(min(z[2] for z in grid.keys()) - 1, max(z[2] for z in grid.keys()) + 2):
for wAxis in range(min(w[3] for w in grid.keys()) - 1, max(w[3] for w in grid.keys()) + 2):
cube = grid.get((xAxis, yAxis, zAxis, wAxis), False)
neighbours = checkAdjacent(xAxis, yAxis, zAxis, wAxis, grid)
if (cube and neighbours in (2, 3)) or (not cube and neighbours == 3):
newGrid[(xAxis, yAxis, zAxis, wAxis)] = True
return newGrid
def checkAdjacent(row, column, depth, w, grid):
neighbours = 0
for dx in (-1, 0, 1):
for dy in (-1, 0, 1):
for dz in (-1, 0, 1):
for dw in (-1, 0, 1):
if dx == dy == dz == dw == 0:
continue
if grid.get((row + dx, column + dy, depth + dz, w + dw), False):
neighbours += 1
return neighbours
def setGrid(lines):
grid = {}
for row, line in enumerate(lines):
for column, depth in enumerate(line):
grid[(row, column, 0, 0)] = depth == '#'
return grid
def main():
start = time.time()
# Execution time: 242.5s
lines = [line.rstrip('\n') for line in fileinput.input("Day17Input.txt")]
grid = setGrid(lines)
for i in range(0, 6):
grid = lifeRound(grid)
print(sum(grid.values()))
end = time.time()
print(f"Executiont time: {end - start}")
main()
oh boy
It only took 250s to run!
yep
2020d17 was 3/4D Game of Life
2020 had a couple different versions of Game of Life
line of sight, 4D, and hexagonal
constrained within six cycles, I'd rather make some sort of ActiveCell class and iterate over them rather than iterating over every single cell, because there'll be so much more empty space as dimension increases
oh wait fuck the births right
since the starting board is 2D, one optimization (that I think the prompt even suggests) is that the results will be symmetrical
ie the board for z=-1 is identical to the board for z=+1
Diagonals don't count.
Good thing it doesn't effect the answer
affect*
Thanks, I never get it right
Verb is "affect", noun is "effect".
(there is a verb "effect", but usage is extremely niche)
And there probably is an input where diagonals would have mattered.
I've been told/taught this as long as I can remember and it still never clicked as to when I need to use one or the other on demand without spending a few minutes trying to remember which one is which lol
affect can be a noun as well
Yes, but people confuse that with "effect" less often.
And it has different meaning.
oh, interesting, I hadn't noticed that
got the correct answer anyway :p
And it’s even more obscure than effect as a verb
good to know this exist