Forum menu
Advent of Code
 

Advent of Code

Posts: 1335
Full Member
 

Day 15 still and a wee optimisation tweak - I was pre-working out and caching some information that I didn't need. So 6ms for part 1 and 2.3s for part 2. That'll do at the moment. I've got a free evening to have a look at Day 16 tonight.

Still "brute-force" but it's just brute forcing a very quick operation. 🙂


 
Posted : 16/12/2022 3:06 pm
 Aidy
Posts: 2977
Free Member
 

Another hard one today


 
Posted : 16/12/2022 6:10 pm
 5lab
Posts: 7926
Free Member
 

yeah I found round 1 easy enough - few bugs but the logic was ok. Took me ages to wrap my head around part 2 - algo ran for 15 mins in the end, so I expect I missed something 😀


 
Posted : 16/12/2022 6:44 pm
 Aidy
Posts: 2977
Free Member
 

I found part 1 pretty hard. My solution for part 2 runs in just over a minute, but I'm really not proud of it.


 
Posted : 16/12/2022 7:01 pm
Posts: 8857
Full Member
 

Just seen this. Will try and play catch up, although my powershell skills are even rustier than last year and I didn't do so well then.


 
Posted : 16/12/2022 9:16 pm
Posts: 1335
Full Member
 

That was ok-ish. Done now and part 2 solves in just under a second. It's not pretty though.

Spoiler
No idea if it's of any interest. Pretty simplistic solution it just explores every step it can from AA (with 2 positions for part 2). I think the reasonable performance is that it generates a load of paths but aggressively gets rid of ones that can't be the optimal solution. That way you're never keeping track of too many routes through the tunnels (max about 4k).

I'm sure there's a better A* way to do it though that is a few milliseconds.


 
Posted : 16/12/2022 9:28 pm
 Aidy
Posts: 2977
Free Member
 

I'm pretty impressed with the proportion of active people to getting solutions on here - I'm in actual programming groups who don't have as good a ratio.


 
Posted : 16/12/2022 10:21 pm
 5lab
Posts: 7926
Free Member
 

found today fairly straight forwards - just a case of chunking through. Still tried to brute force part 2 which is never the right answer 😀

21ms and 310ms respectively


 
Posted : 17/12/2022 3:21 pm
 5lab
Posts: 7926
Free Member
 

and todays is even easier than yesterdays. sub hour for me!

Spoiler
i used a bfs on part 2 to find paths out of the blob


 
Posted : 18/12/2022 9:22 am
Posts: 5300
Full Member
 

Finally got round to completing day 1. Don't think I'll be topping any leader boards.


 
Posted : 18/12/2022 12:47 pm
 Aidy
Posts: 2977
Free Member
 

Had part 1 in about 5 minutes today, flailed a lot with part 2, but got there in the end.


 
Posted : 18/12/2022 2:38 pm
Posts: 1335
Full Member
 

Up to date again. I didn't really enjoy 17 - silly mistake and then an ugly solution:

Spoiler
For the Tetris "can I move left, right?" I was only checking the outside column was clear to move. Worked great most of the time but it was failing at step 27 or something. Easy fix once I worked out where it was failing.

The second part, I was lucky. Lots of visualisation for debugging part 1 then checked what the status was when I was looping the wind to the start of the file and found the picture looked the same. Then an ugly "it gains this many rows for the loop over wind" - different number for the first loop and then the last couple of hundred steps. Dumped the numbers into Excel and worked out total.

.

Day 18 was fun. Liked that.


 
Posted : 18/12/2022 11:29 pm
 Aidy
Posts: 2977
Free Member
 

euain - yeah, I had a silly bug where I'd changed which direction I considered to be up halfway through, and didn't catch all the places.

Part 2 I got more through luck than being clever, I think. It actually fails on the example!


 
Posted : 19/12/2022 12:28 am
 Aidy
Posts: 2977
Free Member
 

Today's is properly wtf.


 
Posted : 19/12/2022 8:32 pm
 5lab
Posts: 7926
Free Member
 

yesterdays took me ages. the thing that got the performance managable (it never finished before) was

Spoiler
a depth first search, but instead of searching 5 options (4 robots and do nothing) I just worked out the min time to each robot (with the right number of no robots) and then added that robot pre-pended with the right number of "no robot" moves to the stack.

today is much easier!


 
Posted : 20/12/2022 1:50 pm
 Aidy
Posts: 2977
Free Member
 

I had a really annoying off by one error that took me ages to find today, but otherwise okay.


 
Posted : 20/12/2022 5:24 pm
Posts: 1335
Full Member
 

Robots was a hard one for me - spent far too long messing about with that.

Spoiler
Eventually managed a pretty basic way to reduce number of branches / discard options by discarding option to make more clay, ore or obsidian robots if we already had enough to saturate production of one obsidian or one geode cracker for the rest of the run. Also added a basic "is this state worse than one I already have" which said if, on the same minute, you have less/equal stocks of all the resources and robots then don't bother adding this new option. These were enough to get part 2 in something like 30s.

Todays was a lot easier though I had to scratch my head to get one case that seems a bit inconsistent.

Spoiler
So if you have 1 2 -2 5 6 or something and process the -2. It had it going to the start of the list rather than looping to after 6. It is covered in one of the samples but I was moving its index from 2 to 0 and putting it into 0. Then my fix for this erroneously put an initial 0 to the end of the list when it wasn't moving. Index 0 to index 0 - oh, invoke the wrap to end case and shove it at the end.


 
Posted : 20/12/2022 7:14 pm
 Aidy
Posts: 2977
Free Member
 

I'm glad I'm not the only person who flailed a bit today

Spoiler

I went straight for a doubly linked list, had off by one errors for when it was moving over itself.

Took me *ages* to find. And, for the first time, I ended up debugging against someone else's solution.


 
Posted : 20/12/2022 8:57 pm
Posts: 1335
Full Member
 

Todays was very nice, I thought.

No complex rules and ended up solving the problem properly (60ms running time, including parsing the file) while my computer was still trying to brute-force the solution (stopped after 2h I could see it was still miles off).

Spoiler
Recursion both ways but for part 2, I worked out that the variable number was only in one location - so in any operation, only one side was dependent on the variable. Just recursed down from "root" setting the value of any operation on the side containing the variable to the value needed to set that monkey's response. Worked first time. Time for lunch.


 
Posted : 21/12/2022 1:49 pm
 Aidy
Posts: 2977
Free Member
 

Yeah, plain sailing today.

The only thing was thinking it'd be quicker to solve the last bit by hand rather than writing code.

Spoiler: It was not.


 
Posted : 21/12/2022 2:28 pm
 5lab
Posts: 7926
Free Member
 

Solved today in the same way I was taught years ago

Spoiler
popping equations off the side which has the human in, inverting them and putting them on the other side until no puzzles are left


 
Posted : 21/12/2022 4:07 pm
 5lab
Posts: 7926
Free Member
 

really easy today I found. just a case of chunking through the problem space. I almost assumed my initial approach (brute force) for part 2 wouldn't work but it was fine!


 
Posted : 23/12/2022 1:05 pm
 Aidy
Posts: 2977
Free Member
 

Just a lot of fiddly code yesterday, didn't enjoy it.

Today's was nice and straight forward, though.


 
Posted : 23/12/2022 2:33 pm
Posts: 1335
Full Member
 

Yesterday's ended up involving drawing shapes on paper and cutting it out. I was convinced I'd find some way of programatically defining the transitions over the edges but ended up just hard-coding the 14 different transitions of my input. Pleased when it worked but not really fun.

Todays was easy enough. I suspect there might be something clever way to do it but my laptop churned through my naive code (with some hideous inefficiencies that I kept thinking "I'll come back and sort in part 2 when I need it to be faster") in less than half a second. I'll leave it there and get on with some proper work.

Part 2 was trivial in mine - I just changed my for loop to execute for ever and added a "if (proposedMoves.isEmpty()){break;}" statement instead.

I'm still waiting for something to cause the levels of pain that the scanners/beacons did last time. That hurt my brain.


 
Posted : 23/12/2022 3:46 pm
 Aidy
Posts: 2977
Free Member
 

Yesterday’s ended up involving drawing shapes on paper and cutting it out.

Yeah, I ended up writing numbers on the sides of a puzzle book (hacked most of it together on a plane, that's what I had a available) to work out the relationships.


 
Posted : 23/12/2022 4:09 pm
Posts: 1335
Full Member
 

High-tech programming

State-of-the-art here... I even drew the shape in Omnigraffle to cut out.


 
Posted : 23/12/2022 4:20 pm
 5lab
Posts: 7926
Free Member
 

yeah I also had a cut out cube 🙂

today was quite simple after all the practice

Spoiler
i used a breadth first search storing the hash of the grid state + move to avoid re-searching existing moves


 
Posted : 24/12/2022 9:29 am
Posts: 1335
Full Member
 

Yup - simple enough today. Quite a relief that I could just add an outer loop to handle part 2. That was unexpectedly easy.

Spoiler
Well it was after I realised I'd been lazy in part 1 and thought we'll have no need to check possible steps from the Exit location so don't worry if we try to move to the row below the grid.

I was getting ready to have to store a big cache of states and positions - I think the states repeat every width x height minutes but both solutions run in <1s so I settled for my simple implementation.


 
Posted : 24/12/2022 8:15 pm
Posts: 1335
Full Member
 

Who's helping the elves out this year?

Nice easy start this year - though I'm being lazy and sticking to my comfy place in Java. Every year I think I'll try to learn something new (Rust, Python,...) but never have the time.


 
Posted : 04/12/2023 9:38 am
 Aidy
Posts: 2977
Free Member
 

Yes, I'm in again. Sticking with Go - I'd like to try a new language, but it's not even like I get to spend much time in the languages I do know lately!


 
Posted : 04/12/2023 1:04 pm
Posts: 988
Free Member
 

Perhaps this will be a good way to see how Chat GPT generates code?


 
Posted : 04/12/2023 1:07 pm
 Aidy
Posts: 2977
Free Member
 

Perhaps this will be a good way to see how Chat GPT generates code?

That was so last year :p


 
Posted : 04/12/2023 1:13 pm
Posts: 1335
Full Member
 

Another year, another AoC adventure.

How's it going this year? So far, a nice gentle easing back into the way of it. Today is an exercise in "read the rules" as I jumped in before I'd read them all.. a couple of wrong answers before I went back and actually read them.. ah, we need to all be in the same direction.. etc.

I suspect it won't be long before it won't be doable over a cup of coffee before work. (By me anyway).


 
Posted : 02/12/2024 10:43 am
 zomg
Posts: 852
Free Member
 

I just read today's. I've not started yet, but it's one of my favourite types of Advent of Code problem. Yay.


 
Posted : 06/12/2024 11:54 am
Posts: 1335
Full Member
 

Agreed, I enjoy this kind of problem. I've got part 1 done but work is getting in the way and I'll not get a chance to play on part 2 until later tonight. Very nerdy, but I'm looking forward to getting stuck in. A couple of ideas how I might do it..

There is a STW AoC leaderboard if you're interested - or maybe you're on it. (I'm not sure who set it up - I think I joined a couple of years ago). If you want, PM me and I'll try to work out what's needed to join it.


 
Posted : 06/12/2024 1:33 pm
Posts: 1335
Full Member
 

It's back on page 2 - posted by @haloric - leaderboard code is: 502307-275d7a99


 
Posted : 06/12/2024 2:24 pm
Posts: 403
Free Member
 

I got a notification !.
I don't use STW any more - feel free to start a new leaderboard or use the existing one to your hearts content.

cheers.


 
Posted : 06/12/2024 2:40 pm
Posts: 2304
Full Member
 

Always fancied trying this and actually giving it a go this year. A bit late but started a bit last night and halfway through day 2 so far... so far so easy, I assume it gets a lot harder!

Anyway it should be a fun challenge, let's see if I can manage it. Only really posting here for motivation so I actually do it and don't procrastinate into oblivion :-p


 
Posted : 11/12/2024 12:49 pm
Posts: 1335
Full Member
 

Anyone partake this year. Only 12 puzzles this time. Most were OK.

Day 10 part 2 was a challenge - ended up taking 3h45 to solve on my laptop. That was after optimising as it had run overnight and only got 10 of the 195 lines solved.  Got the answer though. 🙂

I had my university textbooks ready for a the proper solution but  read the subreddit for some hints and ended up with an algorithm that got the answer in a second. I learned something. 

Other than that, all good fun and 24 stars earned 🙂 


 
Posted : 16/12/2025 7:24 pm
Page 5 / 5