Advent of Code - adventofcode.com

Posted on
Page
of 21
  • I did a super ugly recursive class with a __lt__ and __eq__ operation. Shite but not difficult

  • Day 15 is fun.

    Down to ~100ms (or ~420ms to cover the whole search space if I don't bail early as soon as I get my answer) but I think there might be a way that's nigh on instantaneous, don't have time to think it through properly right now.

  • Day 16.

    First attempt approached it all wrong.

    Got it right on the second go. ~250ms but seems to be non-deterministic (slightly different intermediate results on different invocations) and can't see why, will look at that later and also try and speed it up a bit more.

    Going back to Day 15 first though as I think I've got a much faster approach.

  • Some optimisation over lunch:

    Day 14: Down to 9ms

    • Arbitrary structures as map keys in Go are awesome
    • Another optimisation saved me a good chunk of time

    Day 15: Found a better way for part2 and down to 31ms, might still be able to shave some time off but not today

    16 days in to 2022 and I'm at 305ms so far, with Day 16 taking most of that (~240ms)

  • 16 days in to 2022 and I'm at 305ms so far, with Day 16 taking most of that (~240ms)

    I managed, with some judicious magic numbers in A-* pruning to get day 16 to under 4ms (Python), so more is on the table!

  • Day 19 is fun.

    Got the answers but in 4m24s currently. More search space pruning rules required.

  • Managed to sneak Day 20 in before starting work.

    Had guessed where Part 2 was going so implemented part 1 in such a way that it was easy to tweak for the next bit.

    Runs in ~800ms so still some optimisation work to do, which may require a bit of a rejig.

    Always disconcerting when part2 gives the right answer first time of trying (for both example and my own puzzle input).

    Real life is going to catch up soon (on holiday from 22nd) and have other things to do other than sit in front of a computer, so I guess I'll end up getting the 50th star sometime between the 27th and New Year.

  • [Day 16] Got it right on the second go. ~250ms but seems to be non-deterministic (slightly different intermediate results on different invocations) and can't see why, will look at that later and also try and speed it up a bit more.

    Found the bug, helper function managed to return something other than the shortest route from some valves to other valves. This made it sometimes have less time available for future steps, leading to inconsistent results.

    It's now deterministic but also taking ~800ms (mostly part1) so there's a fair bit I can do.

    Day 19 also down to ~24.5s but still loads of work left to do on that when I get a chance.

    2022: 20 days in and taking 26.197s in total, so my 1s budget is completely blown, but getting all 50 stars is the major priority. Also down to 109 days left to do/redo in Go over all of the years. Slowly and steady...

  • I like checking this thread and thinking “I haven’t got a fucking clue”.

  • All caught up. Hopefully tomorrow is simple as I get about a 15 minute window in the morning and then won't be back to the computer until the evening.

    Lots of work still to do to tidy it all up, especially genericising some of the programs (day 22 especially).

    Some annoying bugs in the last few days that have taken way too long to solve. Certainly eye-opening for my coding process.

  • Managed the first 4 days before getting busy.

    Caught up with days 5 and 6 this morning. The file system one can wait until boxing day :)

  • I've made it halfway. Not sure I'll do much more now. Depends how hard I want to think about part 2 of the monkey one I guess.
    Messy part 1 in jsonnet: https://github.com/rhowe/aoc/blob/main/2022/11-mitm/11part1.jsonnet

  • Managed to get time on Christmas day so I'm all done. Have also done the first round of re-optimisation and all solutions produced in a total of 3.368s 3.050s.

    Notable slow ones are:

    • Day 16 in 0.779s 0.461s
    • Day 19 in 0.540s
    • Day 20 in 0.791s
    • Day 23 in 0.679s
    • Day 24 in 0.473s

    Will do a further round of optimisations when I can be bothered, have thought about how I can make most of them faster but lack the willpower now.

    Also I've (re)done all of the other years up to and including at least Day 10 in Go, but many require further work.

    My own personal optimisation rules:

    • I use sh's time function to time a compiled go program (e.g. the result of go build) so I do have a ~0.001s hit for every execution
    • No parallelisation
    • No picking the magic place or iteration to start a search to get the answer quicker
    • It should be a generic algorithm and not specific to my input (reminds me, I need to make my Day 22 code generic to any input)
    • I won't make my repo public (since it will contain the answers to all puzzles for all years) but I will make occasional days code visible via a gist.
  • Shit, it's back

  • Yup, my early start disrupted by a big night out last night and then a dentist appointment first thing. Just catching up with work and will finish it off. Day 1 not as simple as many of the previous day 1s. Which is nice.

  • LFGSS leaderboard code remains the same: 194911-f096b184

  • Will try and get through a couple of challenges but probably limited to weekends at the moment.

    This was posted in $WORK Slack https://github.com/advent-of-craft/advent-of-craft. Might be if interest.

  • Anyone else getting weird stuff with OAuth? It's prompting me to authorise with 'Advent of Code by Advent-of-Code-Org', which was created less than a day ago, rather the one linked to Eric's account I've used previously.

    I suppose it only wants access to public data, so maybe it's no big deal.

    Edit: apparently legit https://www.reddit.com/r/adventofcode/comments/188bunz/comment/kblcv1j/

  • Day 1 and already there are some pretty nasty edge-cases. 😅

  • Definitely going to do a festive 500: start strong then give up half-way through

  • Day 2 a lot more gentle, easing into it.

    Still need to catch up with previous years rewriting them all in Go. Done loads but still have 90 left to do. Will aim to rewrite 3 or 4 a day and get it done in time for Dec 25th.

  • Whew day 5 is a bit of a gear change

  • I thought so too. Part one was quick for me, thought part two was also gonna be easy... tried to run it with just a couple of modifications but nope, too inefficient to brute force. Ended up taking me a while, but got it to run in 100 ms (not quick compared to many people, but good enough for me).

  • (One day behind due to illness).

    My naive solution brute forced day 5 part 2 in just under 8 minutes. I generally leave such crap running just in case it comes up with an answer before I refactor it to be more efficient. Working on a more efficient solution now although my brain is still a little foggy due to heavy cold/flu like shit.

  • That was quick and easy:

    $ go run 5.go 5.inp
    part1: 174137457
    dur=455.22µs
    part2: 1493866
    dur=513.636µs
    Alloc = 0 MiB   TotalAlloc = 0 MiB      Sys = 11 MiB    NumGC = 0
    

    Under 1ms. That'll do me.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Advent of Code - adventofcode.com

Posted by Avatar for Drakien @Drakien

Actions