Unable to load image

rDrama Advent of Code Day 22: Baby It's Cold Outside Edition

Summary for those just joining us:

Advent of Code is an annual Christmas themed coding challenge that runs from December 1st until christmas. Each day the coding problems get progressively harder. We have a leaderboard and pretty good turnout, so feel free to hop in at any time and show your stuff!

Whether you have a single line monstrosity or a beautiful phone book sized stack of OOP code, you can export it in a nice little image for sharing at https://carbon.vercel.app

What did you think about today's problem?

https://adventofcode.com/2023

Our Code is 2416137-393b284c (No need to share your profile, you have the option to join anonymously if you don't want us to see your github)

31
Jump in the discussion.

No email address required.

A lot of typing, but not that difficult. I wasted a bit of time unnecessarily trying to optimize part 2

https://i.rdrama.net/images/17032259253664954.webp

Jump in the discussion.

No email address required.

This is a cool problem that he could have done a lot with. I'd have liked to see him go full tetris and destroy entire levels or have you score based on how full a level is.

My code is disgusting and I think I got lucky to get a working P1 relatively quickly, because I didn't fancy bug hunting.

I changed my input data structure a few times before settling on a dict of coord -> brick_id for each individual 1x1x1 cube. It makes the code a bit cleaner but still takes 12 mins for part 2. It's day 22 and I'm sick of AoC so I won't be optimising it.

EDIT: on second thoughts I'm surprised that I was able to solve this by moving each brick individually. For day 22 I'd have expected part 2 to not work at all by brute force. The tree solution is much prettier and more efficient

Jump in the discussion.

No email address required.

Python:

https://i.rdrama.net/images/1703245107113132.webp

Relatively simple today. I kinda overengineered it expecting some kind of massive expansion in Part 2 that'd require sparse arrays. Nonetheless it works, though there are some efficiency improvements that could be made.

Jump in the discussion.

No email address required.

Starting to get quiet in these threads.

I'm glad today was a nice little graph traversal problem - after figuring out z-plane intersections at least, I was anticipating really big numbers for part 2 - after the last couple of days being pretty hard.

https://i.rdrama.net/images/17032876740478904.webp

Jump in the discussion.

No email address required.

Fun one, but it has lots of places to mess up that would be hard to debug. I'm glad my part 1 code adapted to part 2 easily.

https://i.rdrama.net/images/1703249825212542.webp

Jump in the discussion.

No email address required.

In theory not difficult, but holy shit did it suck to debug

D←⌈/⍉↑⊃,/r←(⊂2/⊂3/¯1),1 1 1∘+∘⍎¨¨'~'(≠⊆⊢)¨⊃⎕NGET'22.ex'1
dv←{v←0⍴⍨D ⋄ v⊣⍵∘{v[⍵⊃⍺]←⍵}¨⍳≢⍵}
s←{
    v←dv ⍵
    m←{∧/⍵ 0∊⍨v[⍵⊃b]}¨⍳≢b←1⌈0 0 ¯1∘+¨¨⍵
    (m/b)@{m}⊢⍵
}
b←s⍣≡⊢i←{⊃,¨/⊃,/(⊣,⊣-∘(⍳∘|××)-)/¨↓⍉↑⍵}¨1↓r
⎕←+/b∘{(s≡⊢)⍺/⍨⍵≠⍳≢⍺}¨⍳≢b
⎕←+/b∘{+/((s⍣≡)≢¨⊢)⍺/⍨⍵≠⍳≢⍺}¨⍳≢b

If you wanna be a nerd and do it the correct/nonbruteforce way:

v←dv b ⋄ a←0 0 1∘+¨¨b
p←{⍵ 0~⍨∪v[⍵⊃a]}¨⍳≢b
i←⍸¨↓p(∘.∊)⍨⍳≢p ⋄ j←~0=≢¨i
⎕←(≢r)-≢∪∊((1=≢¨)⊢⍤/⊢)i
⎕←+/{≢⍵~⍨{∪∊⍵,⍸j∧0=≢¨~∘⍵¨i}⍣≡⊢⍵}¨⍳≢i
Jump in the discussion.

No email address required.

https://i.rdrama.net/images/17034049586816118.webp

Jump in the discussion.

No email address required.

Two days late but I solved it. My problem was my gravity simulator wasn't stopping when it hit the bottom and was putting one part of falling blocks back on top.

Jump in the discussion.

No email address required.

All i want for cripmas is @Penny return :(

Jump in the discussion.

No email address required.

Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.