2024 day15
This commit is contained in:
parent
7e2d115e36
commit
4da51514aa
@ -86,7 +86,7 @@ static inline bool n_in_array(int * a, int length, int n)
|
||||
return false;
|
||||
}
|
||||
|
||||
int solve(const char * input, int length, predicate_func pred, accumulate_func acc)
|
||||
static int solve(const char * input, int length, predicate_func pred, accumulate_func acc)
|
||||
{
|
||||
const char * end = input + length;
|
||||
|
||||
|
71
2024/day15/input.txt
Normal file
71
2024/day15/input.txt
Normal file
@ -0,0 +1,71 @@
|
||||
##################################################
|
||||
#.O#..O.O..OO..O.OO.#..O...O.O.##O.O..O.O...OOO..#
|
||||
#..#O.........OO.OO......O..#.O.O.O.O....O#OO.O..#
|
||||
##O......O.O...O...O..#.OOO......O.O.O.....O.OOO.#
|
||||
#.OOO#O.O..O...O...O#O...O...O...O#O.......O.OOO.#
|
||||
#.OO...#...#O.#...#...O..O.#.O.OO...#OO.OOO...O.O#
|
||||
#..O..OOO.O......O....O............OO...O.#.#..#O#
|
||||
#OO.OOO#.O.......O##........O..O....O.....#O.....#
|
||||
#...OO..O..OOOO....#..#.OOO.O...O..O.O.....O.....#
|
||||
#..O.#.O.O..........O...#.O........#......O..#.#.#
|
||||
#.O...O#O.O.O......#..O#O....#..O...#....##......#
|
||||
#..O...#.O#..O.....O...O#O.....O#.O#..#...#OOO...#
|
||||
#..O...OO.O............O.#.O.O..O....O.O.O.......#
|
||||
#..OOO.......O.##.O.O.#.O...#.#O#........O.O#O#..#
|
||||
#......#O#.O.#.OO.OO....O..O.O.OO.O#....OO......##
|
||||
#O.#O#...O.OO..O..OO.#..O.O.......O....OOO.......#
|
||||
#.....O.O.O...##O..##.##.O.O#OO.O.#O#........O.OO#
|
||||
#......O.........O..O.#..............#.O.#.O..O..#
|
||||
#.O...O.OOO..O.O.....O...O..O......O.OO...OO..O###
|
||||
#.O....O##O......OOOO..OO...O.....#...O....#..#..#
|
||||
#O....O...O..#....O.....O..#......O....OOO.O.....#
|
||||
#.....#.O..O..O..O.O.OO.O.O.#O.........OO.O.O....#
|
||||
#....O.....O.O....O...O...O...O..O....O...OO..O#.#
|
||||
#..OO..#O.O..O.....O...O..O...O.O....OO...O..#...#
|
||||
#OO..O....O.O.O..O.....O@...OO#....OO.O.OO#O#O.#.#
|
||||
#....O.OO......OO#.OO.O.#OOO.OOO.......#..O..O...#
|
||||
##.O#.O............O...#...OO.OO........OO.OO#...#
|
||||
#O.....O.O#OO........O#O......#...#O.O.OO..O...O.#
|
||||
#.....O.#..OO#.OO...O...O.OO.#O.OO.O......O....OO#
|
||||
#O.#.....##O.O......O...O.O#.O....#O.O..O...O....#
|
||||
#.O#.....#..........O.#..O#..O..O#O...O.#O#O.....#
|
||||
#.#..O.O..#.O##.O.OOO....O....O...OO..O..O...O#..#
|
||||
#O.....O.....O..O.OO.O.......O......O.OO.OO......#
|
||||
#O.OO.O....#..OO..O....O.#...#..#.......O#.OOOOOO#
|
||||
#.............O#OO.#....O.......OO#......O.......#
|
||||
##.OO.O..O.....#..#O....#O.O...#.O..OO....OO.O...#
|
||||
#....O...OO.#..O.OO.OO.OOO........O..........O.O.#
|
||||
#O.O..O.......O...#O...O.O...#...O#.....O...O.O.O#
|
||||
#...#.O..OO.OO....O....O..O...O....O#..OOO.......#
|
||||
#...#..OO..O.......O.O.O.OOO.O.#...O#.#..#O..#...#
|
||||
#.O#..O..OO..#O...O.#.....O..O......OO.OOOO##.O.##
|
||||
#.#O....O.......O.#O.....O....#...O....OO.......O#
|
||||
#...#....O..O..........OO...OO#.....OO..O...O.#O.#
|
||||
#.O.#O.#....O..#.OO.O#..##.....OOO..#OOO...##O..O#
|
||||
#...O...O..OOO......##OOO.....O....#......O..#...#
|
||||
#...O...#O#...#...O.........O.O....#O.OO.....O.OO#
|
||||
#O....O..##.O#....O....#.OOO#O..O..#O....#.O.....#
|
||||
#......#O...OOO...O..#...O.O#...........OO..O...O#
|
||||
#O....O...O...O.#O..O..OOO..#.OO.O.O.........O...#
|
||||
##################################################
|
||||
|
||||
v<<<v<v>^^<><>vv^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<>v<^^<v^^vv^^<<v^>><>^<^><v>><>v>v<>>^><<^v<^^^>>>^<vvv<v<v<<v^<vv<>>v<^>^vvv<>>^>>v^^<<^<<<^>v<<>v<vv><^<<^vv>v>^<v^^><v^<>^>v<v>>^<>v<<v^>v^^<v>^v^>>v^^>^^v^<vvv^v^^v>v^<<<<>>^vv<>>v>vv^<>vv<vv^<v<^vv<<<^<v^^v<^^^^^>^>v^^v^v>v>><v>^>vv>v><^<>vvvv^v>^^vv>>^vvv<v^^<v^><v>^^^v><v^vv<<vv^<^>vv<v>^>>v<vvv<^>vv<^v>^><<<<^>^<v^^v<<<^^<>v^>v^>>v<>>v<<>>^v>^^<<<v><<v>v<^<v<<<>v>>>^^<v^<^>>v>v^<v<^v^<^<>>><^<^v<<^v^vv^><v^<><>>^^<<>^v><><v>>^><v<^^>v>^v<<^<v^^v
|
15
2024/day15/input.txt.h
Normal file
15
2024/day15/input.txt.h
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern uint32_t _binary_2024_day15_input_txt_start __asm("_binary_2024_day15_input_txt_start");
|
||||
extern uint32_t _binary_2024_day15_input_txt_end __asm("_binary_2024_day15_input_txt_end");
|
||||
extern uint32_t _binary_2024_day15_input_txt_size __asm("_binary_2024_day15_input_txt_size");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
21
2024/day15/sample1.txt
Normal file
21
2024/day15/sample1.txt
Normal file
@ -0,0 +1,21 @@
|
||||
##########
|
||||
#..O..O.O#
|
||||
#......O.#
|
||||
#.OO..O.O#
|
||||
#..O@..O.#
|
||||
#O#..O...#
|
||||
#O..O..O.#
|
||||
#.OO.O.OO#
|
||||
#....O...#
|
||||
##########
|
||||
|
||||
<vv>^<v^>v>^vv^v>v<>v^v<v<^vv<<<^><<><>>v<vvv<>^v^>^<<<><<v<<<v^vv^v>^
|
||||
vvv<<^>^v^^><<>>><>^<<><^vv^^<>vvv<>><^^v>^>vv<>v<<<<v<^v>^<^^>>>^<v<v
|
||||
><>vv>v^v^<>><>>>><^^>vv>v<^^^>>v^v^<^^>v^^>v^<^v>v<>>v^v^<v>v^^<^^vv<
|
||||
<<v<^>>^^^^>>>v^<>vvv^><v<<<>^^^vv^<vvv>^>v<^^^^v<>^>vvvv><>>v^<<^^^^^
|
||||
^><^><>>><>^^<<^^v>>><^<v>^<vv>>v>>>^v><>^v><<<<v>>v<v<v>vvv>^<><<>^><
|
||||
^>><>^v<><^vvv<^^<><v<<<<<><^v<<<><<<^^<v<^^^><^>>^<v^><<<^>>^v<v^v<v^
|
||||
>^>>^v>vv>^<<^v<>><<><<v<<v><>v<^vv<<<>^^v^>^^>>><<^v>>v^v><^^>>^<>vv^
|
||||
<><^^>^^^<><vvvvv^v<v<<>^v<v>v<<^><<><<><<<^^<<<^<<>><<><^^^>^^<>^>v<>
|
||||
^^>vv<^v^v<vv>^<><v<^v>^^^>>>^^vvv^>vvv<>>>^<^>>>>>^<<^v>^vvv<>^<><<v>
|
||||
v^^>>><<^^<>>^v^<v^vv<>v^<<>^<^v^v><^<<<><<^<v><v<>vv>>v><v^<vv<>v^<<^
|
15
2024/day15/sample1.txt.h
Normal file
15
2024/day15/sample1.txt.h
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern uint32_t _binary_2024_day15_sample1_txt_start __asm("_binary_2024_day15_sample1_txt_start");
|
||||
extern uint32_t _binary_2024_day15_sample1_txt_end __asm("_binary_2024_day15_sample1_txt_end");
|
||||
extern uint32_t _binary_2024_day15_sample1_txt_size __asm("_binary_2024_day15_sample1_txt_size");
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
190
2024/day15/solution.c
Normal file
190
2024/day15/solution.c
Normal file
@ -0,0 +1,190 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cartesian.h"
|
||||
#include "memory.h"
|
||||
#include "parse.h"
|
||||
#include "printf.h"
|
||||
|
||||
static bool move(char * map,
|
||||
int width, int height,
|
||||
int x, int y,
|
||||
enum cartesian_direction direction,
|
||||
bool commit)
|
||||
{
|
||||
const struct cartesian_neighbor * dir = &cartesian_neighbor[direction];
|
||||
|
||||
int nx = x + dir->x;
|
||||
int ny = y + dir->y;
|
||||
char n = map[ny * width + nx];
|
||||
switch (n) {
|
||||
case '#':
|
||||
return false;
|
||||
case 'O':
|
||||
if (!move(map, width, height, nx, ny, direction, false))
|
||||
return false;
|
||||
move(map, width, height, nx, ny, direction, commit);
|
||||
break;
|
||||
case '[': [[fallthrough]];
|
||||
case ']':
|
||||
{
|
||||
int nxoff = (n == '[') ? 1 : -1;
|
||||
|
||||
bool move2 = true;
|
||||
if (direction == CARTESIAN_UP || direction == CARTESIAN_DOWN)
|
||||
move2 = move(map, width, height, nx + nxoff, ny, direction, false);
|
||||
|
||||
bool move1 = move(map, width, height, nx, ny, direction, false);
|
||||
|
||||
if (!move1 || !move2)
|
||||
return false;
|
||||
|
||||
if (direction == CARTESIAN_UP || direction == CARTESIAN_DOWN)
|
||||
move(map, width, height, nx + nxoff, ny, direction, commit);
|
||||
|
||||
move(map, width, height, nx, ny, direction, commit);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (commit) {
|
||||
char c = map[y * width + x];
|
||||
map[y * width + x] = '.';
|
||||
map[ny * width + nx] = c;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static enum cartesian_direction parse_direction(char c)
|
||||
{
|
||||
switch (c) {
|
||||
case '<': return CARTESIAN_LEFT;
|
||||
case '>': return CARTESIAN_RIGHT;
|
||||
case '^': return CARTESIAN_UP;
|
||||
case 'v': return CARTESIAN_DOWN;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
typedef int (* map_transform_func)(char * map, char c);
|
||||
|
||||
static int part1_map_transform(char * map, char c)
|
||||
{
|
||||
*map = c;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int part2_map_transform(char * map, char c)
|
||||
{
|
||||
switch (c) {
|
||||
case '#': map[0] = '#'; map[1] = '#'; break;
|
||||
case '.': map[0] = '.'; map[1] = '.'; break;
|
||||
case 'O': map[0] = '['; map[1] = ']'; break;
|
||||
case '@': map[0] = '@'; map[1] = '.'; break;
|
||||
};
|
||||
return 2;
|
||||
}
|
||||
|
||||
static const char * parse_map(const char * input, const char * end,
|
||||
int * width, int * height,
|
||||
int * x, int * y,
|
||||
char * map,
|
||||
map_transform_func func)
|
||||
{
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
|
||||
while (input < end) {
|
||||
if (input[0] == '\n' && input[1] == '\n') {
|
||||
*height += 1;
|
||||
input = parse_skip(input, '\n');
|
||||
return input;
|
||||
} else if (*input == '\n') {
|
||||
*height += 1;
|
||||
*width = 0;
|
||||
input = parse_skip(input, '\n');
|
||||
} else {
|
||||
if (*input == '@') {
|
||||
*x = *width;
|
||||
*y = *height;
|
||||
}
|
||||
int char_width = func(map, *input++);
|
||||
*width += char_width;
|
||||
map += char_width;
|
||||
}
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
static void print_map(const char * map,
|
||||
int width, int height)
|
||||
{
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
print_char(map[y * width + x]);
|
||||
}
|
||||
print_char('\n');
|
||||
}
|
||||
print_char('\n');
|
||||
}
|
||||
|
||||
static int gps_coordinate(int x, int y)
|
||||
{
|
||||
return 100 * y + x;
|
||||
}
|
||||
|
||||
static int sum_boxes(const char * map, int width, int height)
|
||||
{
|
||||
int sum = 0;
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
char c = map[y * width + x];
|
||||
if (c == 'O' || c == '[') {
|
||||
sum += gps_coordinate(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
static int solve(const char * input, int length,
|
||||
map_transform_func func)
|
||||
{
|
||||
const char * end = input + length;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
int x;
|
||||
int y;
|
||||
char map[100 * 100];
|
||||
input = parse_map(input, end,
|
||||
&width, &height,
|
||||
&x, &y,
|
||||
map,
|
||||
func);
|
||||
const char * movements = input;
|
||||
while (movements < end) {
|
||||
char c = *movements++;
|
||||
enum cartesian_direction direction = parse_direction(c);
|
||||
if (move(map, width, height, x, y, direction, true)) {
|
||||
x += cartesian_neighbor[direction].x;
|
||||
y += cartesian_neighbor[direction].y;
|
||||
}
|
||||
|
||||
movements = parse_skip(movements, '\n');
|
||||
}
|
||||
|
||||
return sum_boxes(map, width, height);
|
||||
}
|
||||
|
||||
int64_t _2024_day15_part1(const char * input, int length)
|
||||
{
|
||||
return solve(input, length, part1_map_transform);
|
||||
}
|
||||
|
||||
int64_t _2024_day15_part2(const char * input, int length)
|
||||
{
|
||||
return solve(input, length, part2_map_transform);
|
||||
}
|
@ -39,6 +39,8 @@
|
||||
#include "2024/day13/input.txt.h"
|
||||
#include "2024/day14/sample1.txt.h"
|
||||
#include "2024/day14/input.txt.h"
|
||||
#include "2024/day15/sample1.txt.h"
|
||||
#include "2024/day15/input.txt.h"
|
||||
|
||||
static struct start_size sample[][2] = {
|
||||
{
|
||||
@ -155,6 +157,12 @@ static struct start_size sample[][2] = {
|
||||
{ ( char *)&_binary_2024_day14_sample1_txt_start,
|
||||
(uint32_t)&_binary_2024_day14_sample1_txt_size },
|
||||
},
|
||||
{
|
||||
{ ( char *)&_binary_2024_day15_sample1_txt_start,
|
||||
(uint32_t)&_binary_2024_day15_sample1_txt_size },
|
||||
{ ( char *)&_binary_2024_day15_sample1_txt_start,
|
||||
(uint32_t)&_binary_2024_day15_sample1_txt_size },
|
||||
},
|
||||
};
|
||||
|
||||
static struct start_size input[] = {
|
||||
@ -196,4 +204,6 @@ static struct start_size input[] = {
|
||||
(uint32_t)&_binary_2024_day13_input_txt_size },
|
||||
{ ( char *)&_binary_2024_day14_input_txt_start,
|
||||
(uint32_t)&_binary_2024_day14_input_txt_size },
|
||||
{ ( char *)&_binary_2024_day15_input_txt_start,
|
||||
(uint32_t)&_binary_2024_day15_input_txt_size },
|
||||
};
|
||||
|
7
memory.c
7
memory.c
@ -15,3 +15,10 @@ void memory_set_int(int * buf, int c, int length)
|
||||
buf[i] = c;
|
||||
}
|
||||
}
|
||||
|
||||
void memory_copy_char(char * src, int length, char * dst)
|
||||
{
|
||||
for (int i = 0; i < length; i += 1) {
|
||||
dst[i] = src[i];
|
||||
}
|
||||
}
|
||||
|
1
memory.h
1
memory.h
@ -6,6 +6,7 @@ extern "C" {
|
||||
|
||||
void memory_set_char(char * buf, char c, int length);
|
||||
void memory_set_int(int * buf, int c, int length);
|
||||
void memory_copy_char(char * src, int length, char * dst);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
2
runner.c
2
runner.c
@ -38,7 +38,7 @@ bool runner_tick(struct runner_state * runner_state)
|
||||
int year = solution[ix].year;
|
||||
int day = solution[ix].day;
|
||||
|
||||
if (year != 2023 || day != 4) {
|
||||
if (year != 2024 || day != 15) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,8 @@ int64_t _2024_day14_part2(const char * input, int length);
|
||||
void _2024_day14_render(const struct font * font,
|
||||
const struct glyph * glyphs,
|
||||
const void * maple_ft0_data);
|
||||
int64_t _2024_day15_part1(const char * input, int length);
|
||||
int64_t _2024_day15_part2(const char * input, int length);
|
||||
|
||||
struct day_funcs solution[] = {
|
||||
{
|
||||
@ -139,4 +141,9 @@ struct day_funcs solution[] = {
|
||||
{_2024_day14_part1, _2024_day14_part2},
|
||||
_2024_day14_render,
|
||||
},
|
||||
{
|
||||
2024, 15,
|
||||
{_2024_day15_part1, _2024_day15_part2},
|
||||
NULL,
|
||||
},
|
||||
};
|
||||
|
@ -60,4 +60,7 @@ DAY_OBJ = \
|
||||
2024/day14/sample1.txt.o \
|
||||
2024/day14/input.txt.o \
|
||||
2024/day14/render.o \
|
||||
2024/day14/solution.o
|
||||
2024/day14/solution.o \
|
||||
2024/day15/sample1.txt.o \
|
||||
2024/day15/input.txt.o \
|
||||
2024/day15/solution.o
|
||||
|
Loading…
x
Reference in New Issue
Block a user