From 45d6552560d5b52a6b611545aa96c1d95d51d1be Mon Sep 17 00:00:00 2001 From: Michael Adler Date: Mon, 18 Dec 2023 18:44:42 +0100 Subject: [PATCH] Day 17, Part 1: WIP --- input/day17.txt | Bin 0 -> 20044 bytes meson.build | 1 + puzzle/day17.md | 64 +++++++++++++ src/day17/solve.c | 203 +++++++++++++++++++++++++++++++++++++++++ src/day17/solve_test.c | 43 +++++++++ 5 files changed, 311 insertions(+) create mode 100644 input/day17.txt create mode 100644 puzzle/day17.md create mode 100644 src/day17/solve.c create mode 100644 src/day17/solve_test.c diff --git a/input/day17.txt b/input/day17.txt new file mode 100644 index 0000000000000000000000000000000000000000..82073aad001f1c89c8916fe5b4724971eeb8a590 GIT binary patch literal 20044 zcmV(vK~{QM%0JG16ImijtLx;Z(?|MERGa0pJPtR>v4JnrK$ zfd7=Lq!8~g3XOLMdz6< zV&1*PaPmB_suc-^PNEX>8oHo|k^(D2U`2+c-@o;k#)pIb1;>h+#^Naqs|NyfoO1}P z)5yal+oyne0!-BJgL`AKu%C`Id-+jkRSbIF5-Az(089N4vE_5>D8U86oqo>@Ok*N) zlwMB8d{YDyOgJ5cB7FX(oRrBv7Lw;sc8LbH8;E(PG>L!eRWoGx@9EY+$snx?HMf~@ z46xZ^QfjB)B3kWWoJM6^`lLWC;;pVg)irmO?l`Wh$5kkF(v--8e0Hi_3}NRh)OFlN zB!f&=s}Dve1f}cIWkD>*2ey+;rMCobmN4aY94bTM;JgVgiVX56Z8$ZkrIsF{tbczE zo7VJ3TZU-+J?9>UOv+l+-V<>P9(JMbaaTr%zz(kdO^TZivVA2tzqt!E6~Ik1B1c%( z{!+HX?j4p$ofWwxw61-=Bpd2R6YI`O=m8Qy<)?+XW;1yy!NJS6##9V2Q$=J*)b*oK zW36hsdXA~7yA8XG9sVCkKI{y#Bdil>JK3YdhvSRCtvI4)&rnnK+{QXJ6dsE?pGL1v z8z4L^34`e>!8Ltyo)dR!M%{+0|D@PoGgwHF=ZTRf!A?TJX|a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f603 100644 --- a/meson.build +++ b/meson.build @@ -48,6 +48,7 @@ days = { 'day14': [ 'src/day14/solve.c' ], 'day15': [ 'src/day15/solve.c' ], 'day16': [ 'src/day16/solve.c' ], + 'day17': [ 'src/day17/solve.c' ], # XXX: marker } diff --git a/puzzle/day17.md b/puzzle/day17.md new file mode 100644 index 0000000..42284e5 --- /dev/null +++ b/puzzle/day17.md @@ -0,0 +1,64 @@ + +--- Day 17: Clumsy Crucible --- + +The lava starts flowing rapidly once the Lava Production Facility is operational. As you leave, the reindeer offers you a parachute, allowing you to quickly reach Gear Island. + +As you descend, your bird's-eye view of Gear Island reveals why you had trouble finding anyone on your way up: half of Gear Island is empty, but the half below you is a giant factory city! + +You land near the gradually-filling pool of lava at the base of your new lavafall. Lavaducts will eventually carry the lava throughout the city, but to make use of it immediately, Elves are loading it into large crucibles on wheels. + +The crucibles are top-heavy and pushed by hand. Unfortunately, the crucibles become very difficult to steer at high speeds, and so it can be hard to go in a straight line for very long. + +To get Desert Island the machine parts it needs as soon as possible, you'll need to find the best way to get the crucible from the lava pool to the machine parts factory. To do this, you need to minimize heat loss while choosing a route that doesn't require the crucible +to go in a straight line for too long. + +Fortunately, the Elves here have a map (your puzzle input) that uses traffic patterns, ambient temperature, and hundreds of other parameters to calculate exactly how much heat loss can be expected for a crucible entering any particular city block. + +For example: + +2413432311323 +3215453535623 +3255245654254 +3446585845452 +4546657867536 +1438598798454 +4457876987766 +3637877979653 +4654967986887 +4564679986453 +1224686865563 +2546548887735 +4322674655533 + +Each city block is marked by a single digit that represents the amount of heat loss if the crucible enters that block. The starting point, the lava pool, is the top-left city block; the destination, the machine parts factory, is the bottom-right city block. (Because you +already start in the top-left block, you don't incur that block's heat loss unless you leave that block and then return to it.) + +Because it is difficult to keep the top-heavy crucible going in a straight line for very long, it can move at most three blocks in a single direction before it must turn 90 degrees left or right. The crucible also can't reverse direction; after entering each city block, +it may only turn left, continue straight, or turn right. + +One way to minimize heat loss is this path: + +2>>34^>>>1323 +32v>>>35v5623 +32552456v>>54 +3446585845v52 +4546657867v>6 +14385987984v4 +44578769877v6 +36378779796v> +465496798688v +456467998645v +12246868655 + +This path never moves more than three consecutive blocks in the same direction and incurs a heat loss of only 102. + +Directing the crucible from the lava pool to the machine parts factory, but not moving more than three consecutive blocks in the same direction, what is the least heat loss it can incur? + +To begin, get your puzzle input. + +Answer: + +You can also [Shareon Twitter Mastodon] this puzzle. + diff --git a/src/day17/solve.c b/src/day17/solve.c new file mode 100644 index 0000000..cbae747 --- /dev/null +++ b/src/day17/solve.c @@ -0,0 +1,203 @@ +/* + * Author: Michael Adler + * + * Copyright: 2023 Michael Adler + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "solve.h" +#include "aoc/all.h" + +#define GRID_SIZE 256 +#define INFINITY 1 << 30; + +static int grid[GRID_SIZE][GRID_SIZE]; +static int rows = 0, cols = 0; + +/* Dijkstra state */ +static int dist[GRID_SIZE][GRID_SIZE]; +static Point2D prev[GRID_SIZE][GRID_SIZE]; + +typedef struct { + int x, y; + char previous[3]; + int previous_count; +} QueueEntry; + +typedef struct { + int x, y; + char dir; +} Neighbor; + +#define P +#define T QueueEntry +#include + +static void add_point(Neighbor *neighbor, int *neighbor_count, Neighbor p) { + if (p.x < 0 || p.x >= cols || p.y < 0 || p.y >= rows) return; + neighbor[*neighbor_count] = p; + *neighbor_count = *neighbor_count + 1; +} + +void solve(char *buf, size_t buf_size, Solution *result) { + int part1 = 0, part2 = 0; + + for (int pos = 0, x = 0; pos < (int)buf_size; pos++) { + char c = buf[pos]; + switch (c) { + case '\n': + cols = x; + x = 0; + rows++; + break; + default: grid[rows][x++] = c - '0'; break; + } + } + log_debug("rows: %d, cols: %d", rows, cols); + + // Dijkstra + _cleanup_(lst_QueueEntry_free) lst_QueueEntry queue = lst_QueueEntry_init(); + + Point2D undefined = {.x = -1, .y = -1}; + for (int y = 0; y < rows; y++) { + for (int x = 0; x < cols; x++) { + dist[y][x] = INFINITY; + prev[y][x] = undefined; + lst_QueueEntry_push_back(&queue, (QueueEntry){.x = x, .y = y}); + } + } + dist[0][0] = 0; + + Point2D dest = {.x = cols - 1, .y = rows - 1}; + + while (!lst_QueueEntry_empty(&queue)) { + // find min + lst_QueueEntry_node *node = NULL; + int best_d = INFINITY; + foreach (lst_QueueEntry, &queue, it) { + int d = dist[it.ref->y][it.ref->x]; + if (d < best_d) { + best_d = d; + node = it.node; + } + } + QueueEntry entry = node->value; + lst_QueueEntry_erase(&queue, node); + + int dist_entry = dist[entry.y][entry.x]; + + if (entry.x == dest.x && entry.y == dest.y) { + log_debug("found shortest path to dest: %d", dist_entry); + part1 = dist_entry; + break; + } + + bool must_turn = entry.previous_count == 3 && entry.previous[0] == entry.previous[1] && + entry.previous[1] == entry.previous[2]; + log_debug(">> visiting row %d, col %d, dist: %d, must_turn: %d, previous: %.*s", entry.y, entry.x, dist_entry, + must_turn, entry.previous_count, entry.previous); + // check neighbors + Neighbor neighbor[4]; + int neighbor_count = 0; + char direction; + if (entry.previous_count > 0) { + direction = entry.previous[entry.previous_count - 1]; + } else { + direction = '\0'; + } + + Neighbor top = {.x = entry.x, .y = entry.y - 1, .dir = '^'}; + Neighbor bottom = {.x = entry.x, .y = entry.y + 1, .dir = 'v'}; + Neighbor right = {.x = entry.x + 1, .y = entry.y, .dir = '>'}; + Neighbor left = {.x = entry.x - 1, .y = entry.y, .dir = '<'}; + switch (direction) { + case '>': + add_point(neighbor, &neighbor_count, top); + add_point(neighbor, &neighbor_count, bottom); + if (!must_turn) { add_point(neighbor, &neighbor_count, right); } + break; + case '<': + add_point(neighbor, &neighbor_count, top); + add_point(neighbor, &neighbor_count, bottom); + if (!must_turn) { add_point(neighbor, &neighbor_count, left); } + break; + case 'v': + add_point(neighbor, &neighbor_count, left); + add_point(neighbor, &neighbor_count, right); + if (!must_turn) { add_point(neighbor, &neighbor_count, bottom); } + break; + case '^': + add_point(neighbor, &neighbor_count, left); + add_point(neighbor, &neighbor_count, right); + if (!must_turn) { add_point(neighbor, &neighbor_count, top); } + break; + default: + add_point(neighbor, &neighbor_count, top); + add_point(neighbor, &neighbor_count, bottom); + add_point(neighbor, &neighbor_count, left); + add_point(neighbor, &neighbor_count, right); + break; + } + log_debug("found %d neighbors", neighbor_count); + for (int i = 0; i < neighbor_count; i++) { + Neighbor nb = neighbor[i]; + int alt = dist_entry + grid[nb.y][nb.x]; + int old = dist[nb.y][nb.x]; + log_debug("checking neighbor in row %d, col %d, dir %c, alt %d, old %d", nb.y, nb.x, nb.dir, alt, old); + if (alt < old) { + log_debug("!!! found new best dist"); + dist[nb.y][nb.x] = alt; + prev[nb.y][nb.x] = (Point2D){.x = entry.x, .y = entry.y}; + + foreach (lst_QueueEntry, &queue, it) { + if (it.ref->x == nb.x && it.ref->y == nb.y) { + if (entry.previous_count == 0) { + it.ref->previous_count = 1; + it.ref->previous[0] = nb.dir; + } else if (entry.previous_count == 1) { + it.ref->previous[0] = entry.previous[0]; + it.ref->previous[1] = nb.dir; + it.ref->previous_count = 2; + } else if (entry.previous_count == 2) { + it.ref->previous[0] = entry.previous[0]; + it.ref->previous[1] = entry.previous[1]; + it.ref->previous[2] = nb.dir; + it.ref->previous_count = 3; + } else if (entry.previous_count == 3) { + it.ref->previous[0] = entry.previous[1]; + it.ref->previous[1] = entry.previous[2]; + it.ref->previous[2] = nb.dir; + it.ref->previous_count = 3; + } + break; + } + } + } + } + } + + Point2D path[1024]; + int path_count = 0; + Point2D tmp = dest; + while (tmp.x != undefined.x && tmp.y != undefined.y) { + path[path_count++] = tmp; + tmp = prev[tmp.y][tmp.x]; + } + + for (int i = path_count - 1; i >= 0; i--) { printf("row=%d, col=%d\n", path[i].y, path[i].x); } + + aoc_itoa(part1, result->part1, 10); + aoc_itoa(part2, result->part2, 10); +} + +int solve_input(const char *fname, Solution *result) { + char buf[1 << 15]; + int n = aoc_io_read_input(fname, buf, sizeof(buf)); + if (n <= 0) { + fprintf(stderr, "Failed to read %s\n", fname); + return -1; + } + solve(buf, n, result); + return 0; +} diff --git a/src/day17/solve_test.c b/src/day17/solve_test.c new file mode 100644 index 0000000..ba66c78 --- /dev/null +++ b/src/day17/solve_test.c @@ -0,0 +1,43 @@ +/* + * Author: Michael Adler + * + * Copyright: 2023 Michael Adler + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#define CTEST_MAIN + +#include "ctest.h" +#include "solve.h" + +CTEST(day17, example) { + char *buf = "2413432311323\n\ +3215453535623\n\ +3255245654254\n\ +3446585845452\n\ +4546657867536\n\ +1438598798454\n\ +4457876987766\n\ +3637877979653\n\ +4654967986887\n\ +4564679986453\n\ +1224686865563\n\ +2546548887735\n\ +4322674655533\n"; + Solution solution; + solve(buf, strlen(buf), &solution); + ASSERT_STR("102", solution.part1); + // ASSERT_STR("0", solution.part2); +} + +#ifdef HAVE_INPUTS +CTEST_SKIP(day17, real) { + Solution solution; + solve_input("input/" DAY ".txt", &solution); + ASSERT_STR("0", solution.part1); + // ASSERT_STR("0", solution.part2); +} +#endif + +int main(int argc, const char *argv[]) { return ctest_main(argc, argv); }