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?
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)
Jump in the discussion.
No email address required.
I'm still brute forcing day 1![:marseyexcited: :marseyexcited:](https://i.rdrama.net/e/marseyexcited.webp)
Jump in the discussion.
No email address required.
do your best babe!![:marse#ybeefcake: :marse#ybeefcake:](https://i.rdrama.net/e/marseybeefcake.webp)
Jump in the discussion.
No email address required.
More options
Context
More options
Context
Hmm. This was easy to code but there's gotta be a better way. Takes forever to execute. Although after n iterations the answer is consistent so I didn't even run at a million.
I don't get it tho how does this get optimized..? Even if I turn it into 2 things by flipping the table and just doing 1 direction four times, it'd still be the same amount of work wouldn't it..?
Jump in the discussion.
No email address required.
You got lucky.
The main optimization (if it could even be called that) is to find a cycle by storing all states
you get after four tilts (or their hashes), then reduce
that billion iterations modulo the cycle length. That gave me about two minutes' run time in Python
on my data.
The next part I guess
is to make the tilt step dramatically faster by placing the rocks into their final
places immediately instead of running
the cellular automata on the entire grid all the time.
Jump in the discussion.
No email address required.
ah yea ur right I have it assigning the value for each step, would be better to get the final number then do the swap
Jump in the discussion.
No email address required.
More options
Context
For my tilt I just counted the number of 0s between each hash and just placed that many. No need to iterate each of them into place since they're all identical. It runs in order of milliseconds at that point
Jump in the discussion.
No email address required.
More options
Context
More options
Context
You answered your own question.
(1000000000 % cycle length) + offset is how many cycles you need to get the answer.
So for part two all you do is add a 90degree matrix rotation and tilt the table. Then just run until you see the pattern and adjust your required cycles
Jump in the discussion.
No email address required.
I didn't wanna assume cuz what if it's like
where there's a span of seemingly repetitive answers
But I "proved" it by submitted my answer for 100,1000,10000 lawl
Jump in the discussion.
No email address required.
If they managed to design a problem where the data did that it would be REALLY funny
Jump in the discussion.
No email address required.
it took 100000 iterations 80 seconds to run so.. yea pressing ctrl+c in the middle of the full run felt good after the answer got confirmed lolol
Jump in the discussion.
No email address required.
By the way it's not possible to have a loop that would break in this problem.
If the same position is EVER reached again it would work unless some outside stimulus was applied.
Jump in the discussion.
No email address required.
how hard do u think it would be, given the same placement of
#
rocks and same number ofO
rocks, to find what configuration would result in the highest number of iterations required where no more change is possiblee:
I don't think that's tru tho because the answer is itself a hash of the configuration isn't it? There's for sure collisions possible with one
O
switching places vertical places with anotherO
Jump in the discussion.
No email address required.
If they switch places it doesn't matter functionally. It still counts as a cycle for the purposes of this exercise as the only thing that matters is any rock being in that position.
From a black box perspective that cycle will continue forever in terms of output stress even if rocks are swapping positions because those swaps themselves will also be cyclical e.g. if two rocks switch, in another cycle they'll switch back, if three rocks rotate positions they'll be be back to their original position after two cycles and the same slots will still have been filled in the intermediary ones.
Don't consider them swapping a collision unless the two rocks are actually distinct in some way. Otherwise that's like calling binary number 0b101 a collision with 0b101 (with the numbers swapped)
Jump in the discussion.
No email address required.
More options
Context
More options
Context
More options
Context
More options
Context
More options
Context
More options
Context
More options
Context
More options
Context
Figured that the grid would repeat it's position every n cycles, but no, it just stays constant eventually![:marseyshrug: :marseyshrug:](https://i.rdrama.net/e/marseyshrug.webp)
Jump in the discussion.
No email address required.
Lucky bastard mine took 180 cycles before it stabilized with a period of 14
Jump in the discussion.
No email address required.
Watching it go was kinda nerve-racking, especially when it stopped doing
print(c, len(hashes))
and went on to run the cycle for the last time after two minutes or so.edit: especially especially because the last part of the code was this
... and I was, like, where's the complementary "- 1", it should be there for symmetry, aaaaaaahh ok let's run and submit whatever it outputs.
I guess we should've implemented a faster fall down routine, like get all stones sorted by northerness and place each down immediately.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
Mine had a cycle length of 26.
edit: the example grid has a cycle with 7 steps.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
/norotation/ chads gtfih
Also goddamn I hate detecting cycles
Jump in the discussion.
No email address required.
More options
Context
Wasted at least 10 minutes rotating the grid the wrong way. Feels good solving it before bed though.
Jump in the discussion.
No email address required.
data = np.rot90(data, -1)
Jump in the discussion.
No email address required.
More options
Context
Same because multidimensional array syntax is Row,col instead of col,row like in math![:marseytrollcrazy: :marseytrollcrazy:](https://i.rdrama.net/e/marseytrollcrazy.webp)
Jump in the discussion.
No email address required.
More options
Context
easily fricked around for ten minutes on that shit
Jump in the discussion.
No email address required.
More options
Context
More options
Context
Jump in the discussion.
No email address required.
More options
Context
I thought it was an optimization problem, spent one hour caching everything to make sure each cycle was as fast as possible ... then figured out it didn't matter.
Part 1:
Part 2:![:marseysuicide: :marseysuicide:](https://i.rdrama.net/e/marseysuicide.webp)
Jump in the discussion.
No email address required.
I could have used 1 tilt function and a rotation to implement the other 3, but I decided to show how repetitive functions can be deduplicated using templates.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
The fact that cycles are key to solving pt2 makes me wonder if that's just a property of this puzzle or they have a clever way to generate inputs that collapse into cycles. Either way the puzzle author is very clever to work it out
I'm seeing the benefit of those nerds writing generic libraries just for AOC. I've written like 4 or 5 variants of the darn matrix rotation function
Jump in the discussion.
No email address required.
I mean, statistically a problem like this has a finite number of board states (especially after a tilt) so it HAS to collapse into cycles eventually
The real trick is getting them to do it without going on too long, but maybe that's just inherent to the problem.
Jump in the discussion.
No email address required.
More options
Context
More options
Context
Had to rewrite for part 2 because my code sucked butt.
Jump in the discussion.
No email address required.
More options
Context
Snapshots:
https://carbon.vercel.app:
ghostarchive.org
archive.org
archive.ph (click to archive)
https://adventofcode.com/2023:
ghostarchive.org
archive.org
archive.ph (click to archive)
Jump in the discussion.
No email address required.
More options
Context