#Advent of Code 2021

1 messages · Page 1 of 1 (latest)

smoky mauve
pine carbon
#

@fluid remnant what's ur part 1/part2 times

fluid remnant
#

00:04:16 2 21 00:06:32 1 22 43

pine carbon
#

ah

#

I got uh

#
  1   00:00:57    65     36   00:10:54  2713      0

but I think that puts you above me

smoky mauve
#

oh wow

#

that leaderboard placement

pine carbon
#

thats for global
Im actually
so hype rn

fluid remnant
#

wow

smoky mauve
#

that delta tho

pine carbon
#

I had an off-by-1 due to me misreading the question on part 2

slate sail
#

Lol 2 of my friends had that

#

Luckily I didn't

#

How come arson did it faster than abex but got a lower rank?

old tusk
#

w += v[i] - v[i-windowsize+1] 🤡

pine carbon
#

but if you sort by global leaderboard

#

😎 😎

fathom grotto
#

It sure woke me up, if nothing else.

pine carbon
#

factss

fathom grotto
#

Yeah, my time is 1 00:05:54 3356 0 00:10:33 2613 0

#

Barely before you.

pine carbon
#

ah damn

#

oh well

#

nice nice

slate sail
#

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!

smoky mauve
pine carbon
#

Thank you! Unfortunately it will not help me get to sleep any faster lol

#

yea exactly

chilly heart
#

got distracted and missed the start

pine carbon
#

fiddling with the bounds to make it not error cause me to make that mistake

chilly heart
#

1 00:52:16 9788 0 00:54:34 8405 0

pine carbon
#

nice part 2 timing though

chilly heart
#

yeah, i guess

#

easy as shit with python, lol

pine carbon
#

way faster than me:)

chilly heart
#

more_itertools yo

#

it's fucking cheating

smoky mauve
#

I had to think a moment about where to start counting on part 2, especially switching back to a 0-index language

pine carbon
#

you don't actually need the sum to do part 2 either lol

smoky mauve
#

yep

pine carbon
#

I was writing the sum code and thinking

#

"I'm just adding sum to one side and then subtracting it from the other side"

chilly heart
#

yeah i'm optimizing now, i just did it quickly

smoky mauve
#

you're just comparing i with i-1 and then with i-3

pine carbon
#

lesson learned tho, instead of inputs name ins or smth

chilly heart
#

ok i got it to one line. lol

smoky mauve
#

you doing code golf this year?

pine carbon
#

making code look nice

reef ravine
#

Whats this lol

chilly heart
#

I don't really enjoy the "least number of bytes" approach or whatever

pine carbon
#

yea

fathom grotto
fathom grotto
slate sail
#

I love that for pt2 it just boils down to a > d

#

I didn't realise until I made my solutions in unreal blueprints

fathom grotto
#

In what now?

slate sail
smoky mauve
#

now do it with combinators

narrow oxide
chilly heart
#

Yeah that’s essentially my python solution

old tusk
#

C. ||replace 3 with 1 to get the solution for part 1 and make the optimizer think you're on drugs||

pine carbon
#

that's a very C solution

old tusk
#

K&R would be proud I'm sure

chilly heart
#

python
||(ilen(True for w in sliding_window(depths, x) if w[-1] > w[0]) for x in (2, 4))||

ashen tapir
#

Lol y'alls solutions are so elegant

fathom grotto
#

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)

ashen tapir
#

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

chilly heart
#

time since release (0500)

#

if you don't start on time, you just gotta flex your time between parts 1 and 2 🙂

ashen tapir
#

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)

chilly heart
#

yeah. the first few are usually really hard to get good leaderboard ranks on, because they're so easy

ashen tapir
#

how hard do the problems get?

chilly heart
#

my best placement in 2020 was on problem 21

#

go look at previous years and see!

#

day 20 was a doozy

ashen tapir
#

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

fluid remnant
#

I had so many dumb bugs in my day 20 last year. it took forever to make work

chilly heart
#

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

fluid remnant
#

I did part1 fast enough, but it wasn't right enough to do part 2 without fixing the bugs so I went to bed

chilly heart
#

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

ancient light
pine carbon
#

T-1. I can already feel the impact aoc is having on my sleep schedule lol

ancient light
#

you can sleep next year :P

chilly heart
#

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

pine carbon
#

I got the right answer but negative and lost a minute :(

chilly heart
#

didn't try on the test input first? 😦

pine carbon
#

gotta go fast

fluid remnant
#

I spent > 2 minutes because I made up go down and down also go down

pine carbon
#

would've gotten it right if I haven't been a dumbass

smoky mauve
pine carbon
#

u read from the bottom up@chilly heart, then the info is most direct (specific?) to least direct

smoky mauve
#

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 ¯_(ツ)_/¯

chilly heart
#

yeah, fair enough

old tusk
#

I hope the tasks don't take five days to get nontrivial

chilly heart
#

they usually do

fathom grotto
fluid remnant
#

I also forgot that rust's split returns an iterator and not a vec which took a second longer than it should have

pine carbon
#

I need the five days to make my friends who are bad at coding feel like they didn't die on day 3 heh

chilly heart
#

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

smoky mauve
#

||d25p2 is even faster if you know what to expect||

chilly heart
#

just looking at my part1-2 deltas, 2020d10 was the first one that took me >20 minutes for part 2

smoky mauve
#

2020d20 was a pain, I eventually got fed up and had to go to sleep

#

I finished d21 before I finished that

chilly heart
#

yeah, i got pretty crazy with that one

fathom grotto
#

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.

chilly heart
#

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

fluid remnant
chilly heart
#

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

fluid remnant
#

probably yeah

chilly heart
#

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)

slate sail
#

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

fathom grotto
chilly heart
#

nice one

fluid remnant
#

for 18 I just made a tokenizer and then eval'd it with a shunting yard

fathom grotto
#

2020d20p2 is also probably my most commented AoC code ever.

chilly heart
#

mine has no comments. looking at it now is making my head hurt

ancient light
fathom grotto
#

Mine all make sense to me. Remind me how exactly it works, even.

chilly heart
#

meanwhile mine is itertools-heavy code without comments

#

i've trolled myself, basically

fathom grotto
#

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

fathom grotto
#

Yeah, running it through compare, the only difference is the rotated pattern variant.

chilly heart
#

I didn't do well on that one at all

#

premature optimization in part 1 screwed me

pine carbon
#

same, definitely not my best

#

so much words too

fluid remnant
#

yeah

chilly heart
#

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

pine carbon
#

the real question is

#

how do I generalize o2 and co2 finding

#

cause it's one conditional

fluid remnant
#

I just put it in a method passed a bool for which one it was

#

and xored it in the condition

smoky mauve
#

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

fathom grotto
#

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.

opaque carbon
#

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

fathom grotto
#

And p1 turned out completely different from p2 the way I approached it.

chilly heart
#

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

pine carbon
#

best sol for part 1 is matrix transpose

#

:)

chilly heart
#

Yeah basically. Haha

fathom grotto
chilly heart
#

2^n since you’re splitting each time

#

Oh wait, I guess that’s not true

fathom grotto
#

But you don't need the other part.

chilly heart
#

Right, yeah. Haha

slate sail
#

I discovered this lovely thing called Counter from collections and simplified my code a LOT

reef ravine
#

if A does not = B, remove U235

night star
#
def day3a(inparr,mode):
    fun = [float.__lt__,float.__ge__]```
fun!
slate sail
pine carbon
#

hype hype

#

bingo time

smoky mauve
#

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

fathom grotto
#

This one was pretty easy, especially part 2. Took a long time to code though.

fathom grotto
smoky mauve
#

oh, true

#

after losing to it you had to make up Recursive War

fathom grotto
#

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)

fathom grotto
smoky mauve
#

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

slate sail
fathom grotto
#

Took me 20 minutes for that, but that is hardly a complicated task.

smoky mauve
#

it was just a bit tedious

fathom grotto
#

Exactly.

#

(well, you can always reformat your input into a data structure init if you want to go faster)

slate sail
#

Fucking finally, done pt1

night star
#

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 ChibiYelling

#

really need to read slower next time

#

hm, can't spoiler a three tick code block, huh

fathom grotto
#

You can, but it looks awful.

#

Blame Discord.

night star
slate sail
#

Damn that's a smart way of doing it

chilly heart
#

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

night star
#

yes review my code please, because TIL about enumerate

chilly heart
#

it's super useful and lots of people don't know about it

night star
#

it's like I'm missing on how to do for k,v in pairs() but in py

chilly heart
#

for k, v in somedict.items():

night star
#

oh. right, i can do that too

chilly heart
#

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 🤦

night star
#

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

chilly heart
#

ahaha

night star
#

my mind laser-focused on the word WHERE

chilly heart
#

yes, the not stupid way to write that is simpler:
set(board[n:-1:5])

#

i was just brainfarting at the time

night star
#

well, uh, I'm learning here ChibiHappy

chilly heart
#

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

ancient light
#

hm, i should figure out how spoiler tags work

chilly heart
#

can't do spoilers with triple-backtick, so it's a bit subpar for posting code

ancient light
#

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

chilly heart
#

attaching files works because they're collapsed, so as long as the first few lines aren't interesting...

vapid galleon
#

Missed some type hints smh

reef ravine
#

local Debug = true

if debug == true then
print("Debug Screen")
end

fathom grotto
#

A lot of step-by-step solutions (and a lot of Python solutions 🤔 ). I went with something simpler, if perhaps less optimal.

night star
#

too bad discord can't display that directly lol

fathom grotto
#

It works as a spoiler 😛

night star
slate sail
#

So, I guess it's actually the lack of being a fool that made me exclaim that

night star
#

wait, five for loops?

lean karma
night star
#

walrus!

lean karma
#

walrus?

night star
#

:=

lean karma
#

oh, right

#

that's what it's called

slate sail
lean karma
#

have you heard about this thing called a function?

slate sail
#

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()
lean karma
#

oh boy

slate sail
#

It only took 250s to run!

pine carbon
night star
#

Is that basically 4D game of life?

#

oh yeah
it is

smoky mauve
#

yep

#

2020d17 was 3/4D Game of Life

#

2020 had a couple different versions of Game of Life

#

line of sight, 4D, and hexagonal

night star
#

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

smoky mauve
#

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

slate sail
#

Good thing it doesn't effect the answer

fathom grotto
#

affect*

slate sail
#

Thanks, I never get it right

fathom grotto
#

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.

slate sail
#

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

fathom grotto
#

Yes, but people confuse that with "effect" less often.

#

And it has different meaning.

lean karma
#

got the correct answer anyway :p

chilly heart
#

And it’s even more obscure than effect as a verb

spare fiber
#

good to know this exist

chilly heart
#

in response to your comment in #offtopic - if you think day 4 was hard, just wait