Advent of Code
 

  You don't need to be an 'investor' to invest in Singletrack: 6 days left: 95% of target - Find out more

Advent of Code

217 Posts
32 Users
1 Reactions
1,436 Views
Posts: 1318
Free Member
 

First 12 done. Meetings all day today so not even started 13. Might get a chance lunch tomorrow.

It seems easier than last year so far. Only one that’s needed anything really fixed to get from part 1 to 2. Last year there were a few in the first week where you needed to change your algorithm completely to keep the numbers sane.


 
Posted : 13/12/2022 9:43 pm
 5lab
Posts: 7921
Free Member
 

13 was way easier than 12 imo. Just getting through it step by step. Anyone fancy an stw leaderboard?


 
Posted : 13/12/2022 10:22 pm
 5lab
Posts: 7921
Free Member
 

Ok stw leaderboard code is 2114560-90631d35

URL is https://adventofcode.com/2022/leaderboard/private/view/2114560


 
Posted : 13/12/2022 10:25 pm
 Aidy
Posts: 2941
Free Member
 

It seems easier than last year so far.

Yeah, I thought so too. I wondered if it was just because I was more familiar with the style of puzzle.


 
Posted : 13/12/2022 10:25 pm
 Aidy
Posts: 2941
Free Member
 

13 was way easier than 12 imo.

13 had a sneaky case that wasn't covered by the example that caught me out for a couple of minutes, I found 12 fairly straightforward (but we had a pretty similar puzzle last year, and I could remember how I solved it).


 
Posted : 13/12/2022 10:29 pm
 5lab
Posts: 7921
Free Member
 

todays was quite enjoyable, I had a bug in my line drawing which meant it wasn't working quite right, drawing out the grid is quite satisfying for debug purposes


 
Posted : 14/12/2022 10:52 am
 Aidy
Posts: 2941
Free Member
 

I thought today's was pretty dull, tbh. Didn't really have to think and could just tap out a solution.


 
Posted : 14/12/2022 1:33 pm
Posts: 1318
Free Member
 

Caught up now - 13 was a bit messy. 14 was kind of fun but a lot simpler (and I'm sure there's a nicer way to do it than my brute-force way - but I still solved in well under a second.

13 was messy but Part 2 was a doddle by sheer luck - I solved part 1

Spoiler
with a comparator between 2 messages (in Java) which meant that when it came to sorting them, I just shoved the lot into a sorted set and they were sorted for me.

Longest for me so far was day 9 - ropes. Really annoying - all the logic was right but I was only reading one digit of the movement counter.. R 19 was parsing as R 1. Careless mistake but took ages to work it out.


 
Posted : 14/12/2022 5:46 pm
 5lab
Posts: 7921
Free Member
 

yeah I did day 13 the same way as you (albeit in kotlin) so the second part took all of 1 minute to complete..


 
Posted : 14/12/2022 6:01 pm
 Aidy
Posts: 2941
Free Member
 

I stumbled a bit on the second part of the knots one too - turns out actually slowing down and reading the text helps sometimes.

Probably the one that's caught me out for the longest was the second part of day 11.


 
Posted : 14/12/2022 6:15 pm
Posts: 1318
Free Member
 

I was lucky with that one (path finding, wasn’t it?). It was one line of code for me - just had to set everything with height “a” to be reachable in 0 steps. That was a relief as I had to get back to work 😂


 
Posted : 14/12/2022 7:28 pm
 Aidy
Posts: 2941
Free Member
 

11 was the divide by 3 one (turns out that neither longs nor bigints were the answer), path finding one was easy after last year


 
Posted : 14/12/2022 7:31 pm
Posts: 23277
Free Member
 

Did day one earlier in a bit of downtime.

Biggest takeaways for me is how easy vscode web and GitHub codespaces are..


 
Posted : 14/12/2022 9:07 pm
 5lab
Posts: 7921
Free Member
 

urgh part 2 of todays is Tough. took a lot of rework to get mine to perform reasonably (runs in <10s in the end)


 
Posted : 15/12/2022 12:39 pm
 Aidy
Posts: 2941
Free Member
 

Yeah. Took me a while to devise a reasonable algorithm too. Runs in about 2s - could probably shave some off, but that'll do.


 
Posted : 15/12/2022 1:49 pm
 5lab
Posts: 7921
Free Member
 

2s is fast - what approach did you use?

Spoiler
I iterated over the pixels immediately right of the right hand edge of each border, then looked whether that pixel was inside another shape's area. The left edges are covered by the other shapes looking at their right edges..


 
Posted : 15/12/2022 3:07 pm
 Aidy
Posts: 2941
Free Member
 

How do I do spoiler blocks?


 
Posted : 15/12/2022 5:47 pm
Posts: 1318
Free Member
 

I was tying myself in knots today trying to get a clever way to solve part 2. I think I was on the track to doing something nice and fast with overlapping diamonds but in the end I decided to see how long the brute force would take. Ended up being 19s so I'll just take that at the moment. Attack again when I have some time to spare.

Spoiler blocks - put [ then word "spoiler" then ] - close it with [ \ same word ]


 
Posted : 15/12/2022 8:55 pm
Posts: 1318
Free Member
 

Make that 8s on the brute-force method (minor tweaks and realised I was running with Java 8 not 19 - good performance increase). Time to leave the computer, I think.


 
Posted : 15/12/2022 9:20 pm
 Aidy
Posts: 2941
Free Member
 

Ah, I'd been trying with lt/gt tags - like all the other ones.

Spoiler

I basically had an efficient brute force.

Sort the sensors by descending Manhattan number.

Iterate over all the valid values of Y:
Start with a set of intervals [[0,4e6]]
For each sensor; calculate the min, max values of X for the given Y
Subtract this interval from the set of possible X values (e.g. [[0,100]] - [10,20] => [[0,9],[21,100]])
If the set of intervals becomes empty, shortcut to the next Y value
If we reach the end of the sensors, and the set is non-empty, then that's the answer.


 
Posted : 15/12/2022 10:48 pm
Posts: 1318
Free 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 2:06 pm
 Aidy
Posts: 2941
Free Member
 

Another hard one today


 
Posted : 16/12/2022 5:10 pm
 5lab
Posts: 7921
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 5:44 pm
 Aidy
Posts: 2941
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 6:01 pm
Posts: 8669
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 8:16 pm
Posts: 1318
Free 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 8:28 pm
 Aidy
Posts: 2941
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 9:21 pm
 5lab
Posts: 7921
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 2:21 pm
 5lab
Posts: 7921
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 8:22 am
Posts: 5297
Full Member
 

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


 
Posted : 18/12/2022 11:47 am
 Aidy
Posts: 2941
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 1:38 pm
Posts: 1318
Free 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 10:29 pm
 Aidy
Posts: 2941
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 : 18/12/2022 11:28 pm
 Aidy
Posts: 2941
Free Member
 

Today's is properly wtf.


 
Posted : 19/12/2022 7:32 pm
 5lab
Posts: 7921
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 12:50 pm
 Aidy
Posts: 2941
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 4:24 pm
Posts: 1318
Free 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 6:14 pm
 Aidy
Posts: 2941
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 7:57 pm
Posts: 1318
Free 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 12:49 pm
 Aidy
Posts: 2941
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 1:28 pm
 5lab
Posts: 7921
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 3:07 pm
 5lab
Posts: 7921
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 12:05 pm
 Aidy
Posts: 2941
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 1:33 pm
Posts: 1318
Free 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 2:46 pm
 Aidy
Posts: 2941
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 3:09 pm
Posts: 1318
Free Member
 

High-tech programming

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


 
Posted : 23/12/2022 3:20 pm
 5lab
Posts: 7921
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 8:29 am
Posts: 1318
Free 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 7:15 pm
Posts: 1318
Free 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 8:38 am
 Aidy
Posts: 2941
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 12:04 pm
Posts: 957
Free Member
 

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


 
Posted : 04/12/2023 12:07 pm
 Aidy
Posts: 2941
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 12:13 pm
Posts: 1318
Free 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 9:43 am
 zomg
Posts: 850
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 10:54 am
Posts: 1318
Free 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 12:33 pm
Posts: 1318
Free Member
 

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


 
Posted : 06/12/2024 1: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 1: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 11:49 am
Page 3 / 3

6 DAYS LEFT
We are currently at 95% of our target!