Problem difficulty so far (up to day 16)
- Day 15 - Warehouse Woes: 30m00s
- Day 12 - Garden Groups: 17m42s
- Day 14 - Restroom Redoubt: 15m48s
- Day 09 - Disk Fragmenter: 14m05s
- Day 16 - Reindeer Maze: 13m47s
- Day 13 - Claw Contraption: 11m04s
- Day 06 - Guard Gallivant: 08m53s
- Day 08 - Resonant Collinearity: 07m12s
- Day 11 - Plutonian Pebbles: 06m24s
- Day 04 - Ceres Search: 05m41s
- Day 02 - Red Nosed Reports: 04m42s
- Day 10 - Hoof It: 04m14s
- Day 07 - Bridge Repair: 03m47s
- Day 05 - Print Queue: 03m43s
- Day 03 - Mull It Over: 03m22s
- Day 01 - Historian Hysteria: 02m31s
20 Comments
swlabr@awful.systems · 4 pts · 1y
16!
::: spoiler p1 I used A*, though mathematically I would have been fine with Dijkstra's. Also, here's how I remember how to spell Dijkstra: ijk is in alphabetical order. :::
::: spoiler p2 If you've implemented path/back tracking on a search algo before, this wasn't too bad, though instead of tracking best parent you need to track equivalently best parents. Woke AOC trying to normalise families with more than two parents, SMH :::
Architeuthis@awful.systems · 3 pts · 1y
::: spoiler 16 commentary DFS (it's all dfs all the time now, this is my life now, thanks AOC) pruned by unless-I-ever-passed-through-here-with-a-smaller-score-before worked well enough for Pt1. In Pt2 in order to get all the paths I only had to loosen the filter by a) not pruning for equal scores and b) only prune if the direction also matched.
Pt2 was easier for me because while at first it took me a bit to land on lifting stuff from Djikstra's algo to solve the challenge maze before the sun turns supernova, as I tend to store the paths for debugging anyway it was trivial to group them by score and count by distinct tiles. :::
Soyweiser@awful.systems · 3 pts · 1y
Fun fact, dijk means dike (the land/water barrier) in Dutch.
gerikson@awful.systems · 4 pts · 1y
::: spoiler day 18
bit of a breather episode
As long as you ensure A* / Dijkstra's (is there a functional difference if the edge weights are constant?) you'll get the shortest path. Part 2 was just simulation for me, if I started in the state of part 1 it took a minute to run through the rest of the bytes.
:::
swlabr@awful.systems · 2 pts · 1y
::: spoiler yes What is this, day 16? :::
swlabr@awful.systems · 3 pts · 1y
Day 19! (the cuervo gold....)
::: spoiler disc and code Ok so my path to this answer was circuitous and I now hate myself a little.
P1: Ok, a repeated dfs on suffixes. that shouldn't be too hard. (it was not hard)
P2: Ok, a repeated dfs is a little too slow for me, I wonder how I can speed it up?
forgets about memoisation, a thing that you can do to speed this sort of thing up
I guess the problem is I'm doing an O(mn) match (where m is the number of towels, n is the max towel length) when I can do O(n). I'll build a prefix tree!
one prefix tree later
Ok that still seems to be quite slow. What am I doing wrong?
remembers that memoisation exists
Oh I just need to memoise my dp from part 1. Oops.
Anyway posting the code because I shrunk it down to like two semicolons worth of lines.
(
:::
swlabr@awful.systems · 3 pts · 1y
21 (wip)
::: spoiler 2 meme 2 memeious
:::
swlabr@awful.systems · 3 pts · 1y
20: currently a WIP but:
::: spoiler meme Wait, so itβs all grids? π§πΏβππ«π§πΏβπ :::
gerikson@awful.systems · 5 pts · 1y
Skipping this for now, there are only so many grid maps I can take.
swlabr@awful.systems · 4 pts · 1y
Understandable, have a nice day
swlabr@awful.systems · 3 pts · 1y
::: spoiler ok disco It took me too long to read the prompt and see that without the shortcuts, it's a single path. I wasted too much time on search algorithms.
P1: Here's what I did: Walk the path. Every time you hit a new grid, check if the two shortcuts you can take will save you 100 ps.
To calculate the shortcut saving:
If you index every grid position on the main path from 0, then it takes X ps to reach position X, The time it takes to travel from start to X, then a shortcut to Y, then from Y to the end, is X + 1 + (main path length - Y). The time saved is then just Y - X - 1, modulo maybe like 5 fence post errors.
P2. The prompt wasn't really clear about whether or not cheating meant you can only travel through one set of walls before your cheat ends, or if it meant you could just move through walls for 20ps to wherever you could reach. Turns out, it's the latter.
The above formula is then a special case of Y - X - manhattan distance(X, Y). :::
swlabr@awful.systems · 3 pts · 1y
17!
::: spoiler p1 discussion Simultaneously very fun and also the fucking worst.
Fun: Ooooh, I get to simulate a computer, exciting!
Worst: Literally 8 edge cases where fucking up even just one can fuck up your hour. :::
::: spoiler p2 discussion I did this by hand. sort of. I mean I didn't code up something that found the answer.
Basically I looked at the program in the input and wrote it out, and realised that A was essentially a loop variable, where the number of iterations was the number of octal digits A would take to represent. The most significant octal digits (octits?) would determine the tail end of the output sequence, so to find the smallest A you can do a DFS starting from the MS octit. I did this by hand. :::
::: spoiler EDIT: code. Not gonna explain any of it.
:::
zogwarg@awful.systems · 3 pts · 1y
EDIT: I have a sneaking suspicion that the computer will need to be re-used since the combo-operand 7 does not occur and is "reserved".
::: spoiler re p2 Also did this by hand to get my precious gold star, but then actually went back and implemented it Some JQ extension required:
:::
gerikson@awful.systems · 3 pts · 1y
::: spoiler re: p1
I literally created different test inputs for all the examples given and that found a lot of bugs for me. Specifically the difference between literal and combo operators.
:::
zogwarg@awful.systems · 1 pts · 1y
22!
::: spoiler spoilers! Well itβs not a grid! My chosen language does not have bitwise operators so itβs a bit slow. Have to resort to manual parallelization. :::
gerikson@awful.systems · 3 pts · 1y
so many off by one errors
also first time I had to run the code on a desktop machine because my VPS was too slow
Architeuthis@awful.systems · 2 pts · 1y
::: spoiler 22-2 commentary I got a different solution than the one given on the site for the example data, the sequence starting with 2 did not yield the expected solution pattern at all, and the one I actually got gave more bananas anyway.
The algorithm gave the correct result for the actual puzzle data though, so I'm leaving it well alone.
Also the problem had a strong map/reduce vibe so I started out with the sequence generation and subsequent transformations parallelized already from pt1, but ultimately it wasn't that intensive a problem.
Toddler's sick (but getting better!) so I've been falling behind, oh well. Doubt I'll be doing 24 & 25 on their release days either as the off-days and festivities start kicking in. :::
zogwarg@awful.systems · 2 pts · 1y
::: spoiler Hacky Manual parallelization 22-b.jq
Massive time gains with parallelization + optimized next function (2x speedup) by doing the 3 xor operation in "one operation", Maybe I prefer the grids ^^:
:::
Architeuthis@awful.systems · 2 pts · 1y
If nothing else, you've definitely stopped me forever from thinking of jq as sql for json. Depending on how much I hate myself by next year I think I might give kusto a shot for AOC '25
zogwarg@awful.systems · 1 pts · 1y
That's still mostly what it is ^^, though I'd say it's more "awk+sed" for JSON.