Compare commits

...

2 Commits

Author SHA1 Message Date
dobiadi
1f855400aa Day20 Day21 C WIP 2023-12-24 13:01:39 +01:00
dobiadi
1c22f73a2b Day23 C 2023-12-24 01:51:44 +01:00
13 changed files with 899 additions and 0 deletions

BIN
day20/c/day20 Executable file
View File

Binary file not shown.

204
day20/c/day20.c Normal file
View File

@@ -0,0 +1,204 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LINE_MAX_LENGTH 256
#define MAX_CONNECTED 16
#define MAX_MODULES 128
#define MAX_QUEUE 1024
typedef enum module_type {
FLIPFLOP,
CONJUNCTION,
BROADCAST,
} module_type_t;
typedef struct module {
module_type_t type;
char name[16];
int name_length;
int state;
struct module *inputs[MAX_CONNECTED];
int input_memory[MAX_CONNECTED];
int input_num;
struct module *outputs[MAX_CONNECTED];
int output_num;
char output_names[MAX_CONNECTED][16];
int output_name_lengths[MAX_CONNECTED];
} module_t;
typedef struct signal {
int value;
module_t *module;
module_t *source;
} signal_t;
int main() {
char *p, *buf, c, *q;
buf = (char *)malloc(LINE_MAX_LENGTH);
memset(buf, 0, LINE_MAX_LENGTH);
p = buf;
module_t *modules = (module_t*)malloc(MAX_MODULES * sizeof(module_t));
memset(modules, 0, MAX_MODULES * sizeof(module_t));
int modules_num = 0;
while ((c = getchar()) != EOF) {
*p++ = c;
if (c == '\n') {
p = buf;
if (*p == '%' || *p == '&' || *p == '#') {
switch (*p) {
case '%':
modules[modules_num].type = FLIPFLOP;
break;
case '&':
modules[modules_num].type = CONJUNCTION;
break;
}
p++;
} else {
modules[modules_num].type = BROADCAST;
}
q = p;
while(*p != ' ') p++;
strncpy(modules[modules_num].name, q, p - q);
modules[modules_num].name_length = p - q;
p++;
while(*p != ' ') p++;
p++;
// Read outputs
while(*p != '\0') {
q = p;
while (*p != '\n' && *p != ',') p++;
strncpy(modules[modules_num].output_names[modules[modules_num].output_num], q, p - q);
modules[modules_num].output_name_lengths[modules[modules_num].output_num] = p - q;
modules[modules_num].output_num++;
p+=2;
}
modules_num++;
memset(buf, 0, LINE_MAX_LENGTH);
p = buf;
}
}
// Link up modules
for (int i = 0; i < modules_num; i++) {
// Link outputs
int found = 0;
for (int j = 0; j < modules[i].output_num; j++) {
for (int k = 0; k < modules_num; k++) {
if (!strcmp(modules[k].name, modules[i].output_names[j])) {
modules[i].outputs[j] = &modules[k];
found++;
break;
}
}
}
// Link inputs
for (int j = 0; j < modules_num; j++) {
for (int k = 0; k < modules[j].output_num; k++) {
if (!strcmp(modules[i].name, modules[j].output_names[k])) {
modules[i].inputs[modules[i].input_num] = &modules[j];
modules[i].input_num++;
break;
}
}
}
}
// Find start
module_t *broadcast;
for (int i = 0; i < modules_num; i++) {
if (modules[i].type == BROADCAST) {
broadcast = &modules[i];
break;
}
}
signal_t signal_queue[MAX_QUEUE];
unsigned long low_pulses = 0, high_pulses = 0;
int turned_on = 0;
#ifdef PART2
for(unsigned long l = 0; !turned_on; l++) {
#else
for (unsigned long l = 0; l < 1000; l++) {
#endif
memset(signal_queue, 0, MAX_QUEUE * sizeof(signal_t));
int signal_queue_length = 1;
signal_queue[0].value = 0;
signal_queue[0].module = broadcast;
signal_queue[0].source = NULL;
while (signal_queue_length > 0) {
// Pop first
signal_t signal = signal_queue[0];
for (int i = 0; i < signal_queue_length - 1; i++) {
memcpy(&signal_queue[i], &signal_queue[i+1], sizeof(signal_t));
}
signal_queue_length--;
int output;
if (signal.value) {
high_pulses++;
} else {
low_pulses++;
}
if (signal.module == NULL) {
if (signal.value == 0) {
printf("Machine turn on: %lu\n", l+1);
turned_on = 1;
break;
}
continue;
}
switch (signal.module->type) {
case FLIPFLOP:
if (signal.value == 0) {
signal.module->state = !signal.module->state;
output = signal.module->state;
} else {
output = -1;
}
break;
case BROADCAST:
output = signal.value;
break;
case CONJUNCTION:
// Update input memory
for (int i = 0; i < signal.module->input_num; i++) {
if (signal.module->inputs[i] == signal.source) {
signal.module->input_memory[i] = signal.value;
}
}
int all_high = 1;
for (int i = 0; i < signal.module->input_num; i++) {
if (signal.module->input_memory[i] == 0) {
all_high = 0;
break;
}
}
output = !all_high;
break;
}
if (output != -1) {
for (int i = 0; i < signal.module->output_num; i++) {
signal_queue[signal_queue_length].value = output;
signal_queue[signal_queue_length].module = signal.module->outputs[i];
signal_queue[signal_queue_length].source = signal.module;
signal_queue_length++;
}
}
}
}
printf("%lu\n", high_pulses * low_pulses);
free(buf);
free(modules);
}

58
day20/input.txt Normal file
View File

@@ -0,0 +1,58 @@
%db -> cq
%rj -> gp, nd
%ff -> bk
%rc -> gp
%bk -> tv
%xz -> tf, bn
%gs -> bn
%ps -> rs, gp
%jr -> gp, cg
&pm -> vf
%pn -> pp, rt
%nv -> jr
%rs -> nv
%kz -> mj
%nd -> rc, gp
%nm -> rt, db
%dg -> rt, xl
%vg -> gn
%hc -> vr
%ft -> lf, bn
%mj -> hc, cz
%vb -> ft
%qd -> cz, sz
%pp -> rt
%cq -> rt, vg
%sr -> vb
%lf -> vx, bn
%lh -> pn, rt
%ls -> sl, cz
%tv -> gp, rj
%tf -> sr, bn
&mk -> vf
%bs -> rt, lh
%vx -> bn, gs
&bn -> fs, bv, vb, mk, sr, bz, cf
%rr -> ls
%bv -> xz
%hp -> bs, rt
&pk -> vf
%cg -> rq
%gn -> rt, dg
&cz -> hc, kz, rr, hf, sh
%sl -> cz, kz
broadcaster -> sh, nm, ps, fs
%cf -> bv
&vf -> rx
&rt -> pk, xl, nm, vg, db
%xl -> hp
%sh -> rr, cz
%bz -> cf
%fz -> dn, cz
&gp -> rs, nv, pm, cg, ff, bk, ps
%fs -> bz, bn
&hf -> vf
%vr -> cz, qd
%rq -> gp, ff
%sz -> cz, fz
%dn -> cz

5
day20/sample.txt Normal file
View File

@@ -0,0 +1,5 @@
broadcaster -> a, b, c
%a -> b
%b -> c
%c -> inv
&inv -> a

5
day20/sample2.txt Normal file
View File

@@ -0,0 +1,5 @@
broadcaster -> a
%a -> inv, con
&inv -> b
%b -> con
&con -> output

BIN
day21/c/day21 Executable file
View File

Binary file not shown.

102
day21/c/day21.c Normal file
View File

@@ -0,0 +1,102 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LINE_MAX_LENGTH 256
typedef enum tile_type {
GARDEN_PLOT,
ROCK,
WALKED,
} tile_type_t;
int main(int argc, char *argv[]) {
if (argc != 2) {
fprintf(stderr, "Please specify the step number\n");
return 1;
}
int step_number = 0;
sscanf(argv[1], "%i", &step_number);
char *p, *buf, c;
tile_type_t map[LINE_MAX_LENGTH][LINE_MAX_LENGTH];
int x = 0, y = 0;
buf = (char *)malloc(LINE_MAX_LENGTH);
memset(buf, 0, LINE_MAX_LENGTH);
p = buf;
int start[2];
while ((c = getchar()) != EOF) {
*p++ = c;
if (c == '\n') {
p = buf;
x = 0;
while (*p != '\n') {
switch (*p) {
case '.':
map[x][y] = GARDEN_PLOT;
break;
case '#':
map[x][y] = ROCK;
break;
case 'S':
map[x][y] = GARDEN_PLOT;
start[0] = x;
start[1] = y;
break;
}
x++;
p++;
}
y++;
memset(buf, 0, LINE_MAX_LENGTH);
p = buf;
}
}
tile_type_t walked_curr[LINE_MAX_LENGTH][LINE_MAX_LENGTH], walked_next[LINE_MAX_LENGTH][LINE_MAX_LENGTH];
memcpy(walked_curr, map, sizeof(map));
walked_curr[start[0]][start[1]] = WALKED;
for (int i = 0; i < step_number; i++) {
memcpy(walked_next, map, sizeof(map));
for (int j = 0; j < y; j++) {
for (int k = 0; k < x; k++) {
if (walked_curr[k][j] == WALKED) {
// UP
if (j > 0 && walked_next[k][j-1] == GARDEN_PLOT) {
walked_next[k][j-1] = WALKED;
}
// LEFT
if (k > 0 && walked_next[k-1][j] == GARDEN_PLOT) {
walked_next[k-1][j] = WALKED;
}
// DOWN
if (j < y - 1 && walked_next[k][j+1] == GARDEN_PLOT) {
walked_next[k][j+1] = WALKED;
}
// RIGHT
if (k < x - 1 && walked_next[k+1][j] == GARDEN_PLOT) {
walked_next[k+1][j] = WALKED;
}
}
}
}
memcpy(walked_curr, walked_next, sizeof(map));
}
int part1 = 0;
for (int i = 0; i < y; i++) {
for (int j = 0; j < x; j++) {
if (walked_curr[j][i] == WALKED) {
part1++;
}
}
}
printf("%i\n", part1);
free(buf);
}

131
day21/input.txt Normal file
View File

@@ -0,0 +1,131 @@
...................................................................................................................................
...##......#....#...#.....#.#....#...#...#...#......#........................##......#..#..#.#........#....................##......
...#.......#..........#..#....#................#...##.....##...................#..........###......#.....#.........#....#.#........
........#..##.............#..#...##...#..#...##...............................#.........................#..........................
..............#............#..#..........#.#.#....#...#......................#..#......#.##...#............................#.......
..##...............#...#...#......#.......................................#..............##...............#.....#...........#...#..
.##............#.................#...#..#......#...................................#.......#.#..#......##................##........
......###...#...#........#..............#....#.......##.......................##.......#..#.......#.........#...................#..
.................#...........................................#......................#.....#.....##...........#...............#.....
..#...#....#.......##...........#..#.............#............................##........#.......#...#...#...#....#....##...........
..............#..#.....#.....#.........#..#..#..#..#.......#.#..#....##........#.....#.........#..............#........#..#...#....
...##...............#...#.#....#............##..#.......................................#.......#...........#..#...........##....#.
.......................................#......#...........#..........#.............#..........##.............#....#..##....#.......
..................................#.............#........#...#.##.....................#....................#.##....#.............#.
.#......##...#......#..#...#...........#...#.............#.............#..#.........#..#.#........#.#...........#..................
............#............#..........#........#..........#.....#.#...#.......#........#.#...........#....#.............#.........#..
.....#.......##............#...#.#.#...#...#..............##..#....#......#......................#...#...#..........#......#.#.....
........#....#....#......#..........#........................#.....#....................................#.....#....#..##.##....#...
............#.................#.##.........#.........#.....#........#.........#........#....###...........#.............#..........
....##....#..#............#...#.#..#.........................#.#....##.....................#........#.........#....#....#........#.
...#...#...........#..#..................#.......#.#..#............................................##................#.............
...........#......#....#........#.#..........................#.#......#......##.............#..#...#...#.#..................#..#...
.............................#........#............#........#........#.#.......#...............##....#........#...#..#..#..........
..................................#...........................#.#..#.........................#...#.#......#..............##.....##.
........................#..........................#..................#...#............................#.......#...........#...##..
.......#.#.....#....#.....#................................##...#.........##..#.....................#..............................
......#........##..........#.................#..##......#..#.......#..........#....................................................
....#..........#......................................................##.#..#.#.##..................#......#............##...#.....
.............#..........#.#..............................................#.#........#....#...........#.......................#.....
..#.............#....#........#.#..............#.......#......#.#..#......#.#...........................................##.........
..#.....#.....#....#...#....#..........#......#..............................#...........#............#..#.....##..........#.......
......#.#.#...#........................#..........#.#......#............#......................................#...................
.#...........#...#....................#..#..#....#.#........................................................................#.#....
........#.#...........................#...#......#.#.#..#......##..#.#..#..#...#.#.#..................#.......##.#....#........#...
......#......#......#.....#..............#.#.........##.................#....................#............#....##........#.........
........#.............#..#............#......#........#....#............#.....#...........#..#...............###........#.....#....
.....#.........##....#..................#..#...........#.#....##...........................#.............#..##..#.........#........
............#....#..#.................#.............#..#.....##.....#.....#.........#........#............#........#.........##....
.#.......#.#..........#...............#..............#.....#........#...#......#......##...........................#..#.#......##..
.##.#.........#.............................#............................#.#..#...#.............#...#.........#...#......#.........
................................#........#..#..........##......#..................................#................#.#...#...#.....
.........#........#...........#........................#.#.##.........#.....#..#................................#.............##...
.........#.#....#..#.........#.#....#.......#.............#........#............#...#..........#...##..........#........#........#.
..............................###.....#......#......#...#....#...........#...#...............#.....##.#.....................#..#...
..........................#......#...#..............................##.#.......#........##..........#................#...##.....#..
...........#............................#..................#...#..#.....................#...#.................................#....
..#.#...............................................#..........#..........#..............#............##...........................
........#...#..................#.........#............#...............#.#..#.........#....#...............#.............##.........
............................##....................##......#..#....#.......#....#........................#...#.........#.....#....#.
.....#.#...............#....#..#....#...........#........#.#..................#.....##....#.......#......#......................#..
...........#.........#.#.......#......#.#.#.......#.#...#...................#...#......#..............#...#....#.................#.
...#..#...........#.............#..........##..............................###...........#.#.....##.......#.............#..........
...##.....................##...#..#.....#.........#.#....#.#.....................#..............#.#...#...#......#..............#..
......##................#.................#.#........#.#..#................#............#......#.#..............#...............#..
.......#...........#.................................##..................#...#........#.......#..##...##...........#.........#.....
..............#........#.............#..........#...............#..#.......#.........#..#...............#......#..#.........##.#...
.....#..........................................#...............#....#......#..#................................#...............#..
...............#.......#..#.........#......#..................#........#................#.#...........#....##......#............#..
...........................#.....##.........#...#...........#........#..#................#.#.#............#..#...#.....#...........
................#.....#..#.#......#.............#.....#...........##....#...#.#.....#.........#....................................
....................................#...........#..............#................#............#..#...............#.##..#.##.........
.........#.#..............#........#.........#..#...#........#............##......##.......#....##.............#...................
..........##.....................#................#...#....#........#.....#..........#........#................#..###..............
......................#............................#........................#.#..#..........#......................................
........#...........#.#....#.........#.....#..........#..#.#..............#.......................#..#................#.#..........
.................................................................S.................................................................
.........#.....#..#..........#.....#...........#...............##..#...............#.##....#...........#........#.#....#....#......
.........##...#......#..#.#................#...........#..#...........#...#....#..............#......#..#.................##.......
.....................##.....................##...#.......#......#.............................#..#.................................
........................#..............#....#.................#....#...........#.................#...#.........#........#..........
.........#..#.#...#.#..................#..............#.#...###....#......#......#.#....#..##..............#............#..........
..#.......#...#..............#...#..##............#.........#......#.#....#.#..........................#......#..#.....#...........
..#........#......##.............................#..............#..#....................##.......#....#..#..#..........#...........
.....................#.....#...........#.##................#.#....#.#.#............#...#..##.............#.....##..................
..##............#........#........#...#......#..........##.................#...#.#..........#...................................##.
...#.............#....#...#..#........#.........#......#..................#..#..#..........#.....#........#.#....##............#...
...#.............#...............................#.......#....#..........#..........................##......##...#.............#...
....#................#..#.#................#.....#.......#..................#.......................#.#............................
....#.#..............#..#.........#..#..#................#..#...#.#..............#......#...................#......................
.#......#....................#.................#........##......#......##..........#...............#..##.#.....#.............#.....
...##................#..........#......##.....#........#...#..................#........#......#....#..#.....#......................
......#..................#......#.......#.......#..............#......#.........#.......#..#.#.#...##.....#.............#..........
.#...................#...#....#......#.#.....#.....#..................#.#......#.......#.....#..#......................#.....#.....
...#......................#.......#..#.........#............#...#......##..........#...............................................
...#..#........#........#...........#.#...#...#.#..#.#...#..................#........#........#.#.##...#...........#...............
........#.......................#.............#....#...##.........#....................................#..............#...#........
...#...........##........#..#.......#...............................#..................#.....#.......#.#.........#.................
..........#...............#.###...................#..................................#.....#...#................##...............#.
..#......#..........................#...........................#..................#..#........#....##...................##......#.
....#...........#..#..........................#......###................#...........................#.........#.#........#.#.......
...#...#..#........#...............#...........#.......#........................##..#...............#............#...........#.....
.....#..........................#..#........#.......#......#......#..........#..#.....#.....#..#.................#........#........
....#...##.......................#...#.....#.....................................##.#..#....#....#................#................
..#.....##.........#..............#.#................#.........#...#.................#.........#..............................#....
............#...........#........#........................#.#.......#..#..#.........##...................#......##.#.......#.......
.........#......#......#............#.....#...##...#...............................#.....#..............##............#..#.....##..
...........................#.................#...........#.........#....#.#.#....#......#..#....................#......#...........
....#.#..............................#......#..........#...........#....#.............#.#..............................#.....#..#..
...........#...........#.............##....#......#.........#................#........#...............................#............
...#........#.#....#.....................#..........#.......#...#.........#..........................##........#.#.#...##..........
....#.#....#.........#.......#....................#...........#..........#....#......................#.............#.....#..#....#.
..........#................................#......#....#......#.................................................#..................
.............#................................#...#.##.#.....#.......#....#............###.......#........##.......................
..........#......##.............#.........#............................#.#..#.......................................#.....#......#.
...#.....#.......#............#.............#.#...#.....#.............#..#..........##.......................#.....................
..........................#......#..................#..#........#............#.......##......................###.......#.....#.....
............#.#....#.#................................##......#..............#..#.#........................#......#...#...#........
......##..........#......###...#......................#.........#.#............#..............#......#..............#.......#......
............#........#.....#........#..#.......#...#...................#.....#..................##.............#.................#.
........#.#........##..................................#......#......................................#.....................#.#...#.
.#.......##......#.....#..........#................#...................##..#...............#.......##....................#.........
...#..#..#.............................#...................#................#....................................#........#........
.....#....................................#.........##.............#...........................#...................................
............................#....#......#...................#..................................#...........................##......
...............#...#..#...#.###.#...........#..............#..........#...............##........#.##.#....#.#.............##.....#.
...........#.##......#...#.#.........#.#.#...#.........................................#..........#.............#.#.............#..
........#...............#........#........................#.#......#......#......................#...........#.........#.#...#.....
....#..#.............#......................#...................#.....##...............#...#........#.................#............
............#......#...#.....#..........#....#...............##.....##..#.........#....#..#.......#...#..#.........................
......#...........#.......#...#.#.....#...#......#...........#......#................#................#....#.#...#.................
.......#.#...#.......#......#.................................#..............................#...........#.............#.........#.
...................................#.....#.........#.............................#..#............#...................#...#.........
...............#......#...........................#................#...............##...........#......#........#....##......#.#...
...............#....................##....#...#.....#.................................#..#.............#.#..#.....#..#.#...........
.............................#......##..#........................................##....#.................#......#....#...#.........
......#.#.#...............#.......#............................................................#................#..........#..#....
...#.#...........#..#......#....###...............#..#..#......................#....#..............#......#................#.......
.......................#....#.....#..#.##.#..........#.....................#..................................#....####.##.........
......#..........##...#...........................#....#.................#........#.......................#.................#..#...
.................#..#...................#..#...#...##...#..................#..........#.#....#..#...........................#....#.
...................................................................................................................................

11
day21/sample.txt Normal file
View File

@@ -0,0 +1,11 @@
...........
.....###.#.
.###.##..#.
..#.#...#..
....#.#....
.##..S####.
.##..#...#.
.......##..
.##.#.####.
.##..##.##.
...........

BIN
day23/c/day23 Executable file
View File

Binary file not shown.

219
day23/c/day23.c Normal file
View File

@@ -0,0 +1,219 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#define LINE_MAX_LENGTH 256
#define MAX_QUEUE 256*256
#define cmp(a,b) ((a)[0] == (b)[0] && (a)[1] == (b)[1])
#define abs(a) ((a) < 0 ? -(a) : (a))
typedef enum tile_type {
PATH,
FOREST,
SLOPE_UP,
SLOPE_DOWN,
SLOPE_LEFT,
SLOPE_RIGHT,
} tile_type_t;
int check_direction(int curr[2], int dir[2], uint8_t **visited, tile_type_t map[LINE_MAX_LENGTH][LINE_MAX_LENGTH]);
int highest_cost(int curr[2], tile_type_t map[LINE_MAX_LENGTH][LINE_MAX_LENGTH], int x, int y, uint8_t **visited, int cost, int finish[2], int ignore_slopes, int walkable);
int curr_max = 0;
int directions[4][2] = {
{0, -1},
{0, 1},
{-1, 0},
{1, 0}
};
int main() {
char *p, *buf, c;
buf = (char *)malloc(LINE_MAX_LENGTH);
memset(buf, 0, LINE_MAX_LENGTH);
p = buf;
tile_type_t map[LINE_MAX_LENGTH][LINE_MAX_LENGTH];
int x = 0, y = 0;
int walkable = 0;
while ((c = getchar()) != EOF) {
*p++ = c;
if (c == '\n') {
p = buf;
x = 0;
while (*p != '\n') {
switch (*p) {
case '.':
map[x][y] = PATH;
walkable++;
break;
case '#':
map[x][y] = FOREST;
break;
case '^':
map[x][y] = SLOPE_UP;
walkable++;
break;
case 'v':
map[x][y] = SLOPE_DOWN;
walkable++;
break;
case '<':
map[x][y] = SLOPE_LEFT;
walkable++;
break;
case '>':
map[x][y] = SLOPE_RIGHT;
walkable++;
break;
}
x++;
p++;
}
y++;
memset(buf, 0, LINE_MAX_LENGTH);
p = buf;
}
}
int start[2], finish[2];
start[1] = 0;
finish[1] = y - 1;
// Find start and finish
for (int i = 0; i < x; i++) {
if (map[i][0] == PATH) {
start[0] = i;
}
if (map[i][y - 1] == PATH) {
finish[0] = i;
}
}
uint8_t **visited = (uint8_t**)malloc(x * sizeof(uint8_t*));
for (uint8_t i = 0; i < x; i++) {
visited[i] = (uint8_t*)malloc(y * sizeof(uint8_t));
memset(visited[i], 0, y * sizeof(uint8_t));
}
printf("Part 1: %i\n", highest_cost(start, map, x, y, visited, 0, finish, 0, walkable));
for (uint8_t i = 0; i < x; i++) {
memset(visited[i], 0, y * sizeof(uint8_t));
}
printf("Part 2: %i\n", highest_cost(start, map, x, y, visited, 0, finish, 1, walkable));
free(buf);
for (int i = 0; i < y; i++) {
free(visited[i]);
}
free(visited);
}
int highest_cost(int curr[2], tile_type_t map[LINE_MAX_LENGTH][LINE_MAX_LENGTH], int x, int y, uint8_t **visited, int cost, int finish[2], int ignore_slopes, int walkable) {
if (cmp(curr, finish)) {
return cost;
}
// We will never reach the end
if ((walkable - cost) < (abs(finish[0] - curr[0]) + abs(finish[1] - curr[1])) || visited[finish[0]][finish[1]-1]) {
return -1;
}
visited[curr[0]][curr[1]] = 1;
int *options[4], options_num = 0, *dir, max = 0;
if (map[curr[0]][curr[1]] == SLOPE_UP && !ignore_slopes) {
dir = directions[0];
if (check_direction(curr, dir, visited, map)) {
options[0] = dir;
options_num = 1;
}
} else if (map[curr[0]][curr[1]] == SLOPE_DOWN && !ignore_slopes) {
dir = directions[1];
if (check_direction(curr, dir, visited, map)) {
options[0] = dir;
options_num = 1;
}
} else if (map[curr[0]][curr[1]] == SLOPE_LEFT && !ignore_slopes) {
dir = directions[2];
if (check_direction(curr, dir, visited, map)) {
options[0] = dir;
options_num = 1;
}
} else if (map[curr[0]][curr[1]] == SLOPE_RIGHT && !ignore_slopes) {
dir = directions[3];
if (check_direction(curr, dir, visited, map)) {
options[0] = dir;
options_num = 1;
}
} else {
for (int i = 0; i < 4; i++) {
int *dir = directions[i];
if (check_direction(curr, dir, visited, map)) {
options[options_num] = dir;
options_num++;
}
}
}
if (options_num == 0) {
return -1;
}
uint8_t ***visited_copies = (uint8_t***)malloc(options_num * sizeof(uint8_t**));
for (uint8_t i = 0; i < options_num - 1; i++) {
visited_copies[i] = (uint8_t**)malloc(x * sizeof(uint8_t*));
for (uint8_t j = 0; j < y; j++) {
visited_copies[i][j] = (uint8_t*)malloc(y * sizeof(uint8_t));
memcpy(visited_copies[i][j], visited[j], y * sizeof(uint8_t));
}
}
for (int i = 0; i < options_num; i++) {
int next[2];
next[0] = curr[0] + options[i][0];
next[1] = curr[1] + options[i][1];
int c;
if (i != options_num - 1) {
c = highest_cost(next, map, x, y, visited_copies[i], cost + 1, finish, ignore_slopes, walkable);
} else {
c = highest_cost(next, map, x, y, visited, cost + 1, finish, ignore_slopes, walkable);
}
if (c > max) {
max = c;
}
}
for (int i = 0; i < options_num - 1; i++) {
for (int j = 0; j < y; j++) {
free(visited_copies[i][j]);
}
free(visited_copies[i]);
}
free(visited_copies);
if (max > curr_max) {
curr_max = max;
printf("Current best: %i\n", curr_max);
}
return max;
}
int check_direction(int curr[2], int dir[2], uint8_t **visited, tile_type_t map[LINE_MAX_LENGTH][LINE_MAX_LENGTH]) {
int next_x = curr[0] + dir[0];
int next_y = curr[1] + dir[1];
if (next_y > 0 && !visited[next_x][next_y] && map[next_x][next_y] != FOREST) {
return 1;
}
return 0;
}

141
day23/input.txt Normal file
View File

@@ -0,0 +1,141 @@
#.###########################################################################################################################################
#.#...#...#.....###...#.......###...#####...#...#...#...#...#...#.......#...#.....#.....#.......#...#...#...###...#.....#.....#.............#
#.#.#.#.#.#.###.###.#.#.#####.###.#.#####.#.#.#.#.#.#.#.#.#.#.#.#.#####.#.#.#.###.#.###.#.#####.#.#.#.#.#.#.###.#.#.###.#.###.#.###########.#
#.#.#.#.#.#.#...#...#.#...#...#...#...#...#...#.#.#.#.#.#.#...#...#.....#.#.#...#.#.#...#.....#.#.#...#.#.#...#.#.#.#...#...#.#.....#.....#.#
#.#.#.#.#.#.#.###.###.###.#.###.#####.#.#######.#.#.#.#.#.#########.#####.#.###.#.#.#.#######.#.#.#####.#.###.#.#.#.#.#####.#.#####.#.###.#.#
#...#.#.#.#.#...#.#...###.#...#.#...#.#.....#...#.#...#.#.#.........#.....#...#.#.#.#...#...#.#.#.#.....#.#...#.#.#.#...#...#.#.....#...#...#
#####.#.#.#.###.#.#.#####.###.#.#.#.#.#####.#.###.#####.#.#.#########.#######.#.#.#.###.#.#.#.#.#.#.#####.#.###.#.#.###.#.###.#.#######.#####
#.....#.#.#.###...#.#...#.#...#.#.#...#.....#.#...#...#.#.#.###.....#.....#...#.#.#.#...#.#.#.#.#.#...###.#...#.#.#...#...#...#.....#...#...#
#.#####.#.#.#######.#.#.#.#.###.#.#####.#####.#.###.#.#.#.#.###.###.#####.#.###.#.#.#.###.#.#.#.#.###.###.###.#.#.###.#####.#######.#.###.#.#
#.#...#.#...#.....#.#.#.#.#...#.#.>.>.#.....#.#.#...#...#.#...#.#...###...#.#...#...#.#...#...#.#.#...#...#...#.#.###.#.....#...#...#...#.#.#
#.#.#.#.#####.###.#v#.#.#.###.#.###v#.#####.#.#.#.#######.###.#.#.#####.###.#.#######.#.#######.#.#.###.###.###.#.###.#.#####.#.#.#####.#.#.#
#...#...#...#.#...#.>.#.#.###.#.#...#.......#.#.#.#.>.>.#.#...#.#...#...#...#.#.....#.#.....#...#.#.###...#.#...#...#.#.#...#.#.#...#...#.#.#
#########.#.#.#.###v###.#.###.#.#.###########.#.#.#.#v#.#.#.###.###.#.###.###.#.###.#.#####.#.###.#.#####.#.#.#####.#.#.#.#.#.#.###.#.###.#.#
###.....#.#...#.#...###.#.#...#.#...###...###...#...#.#.#.#...#...#.#.#...###...#...#.#...#.#...#.#.>.>...#.#.#.....#.#.#.#.#.#.#...#.....#.#
###.###.#.#####.#.#####.#.#.###.###.###.#.###########.#.#.###.###.#.#.#.#########.###.#.#.#.###.#.###v#####.#.#.#####.#.#.#.#.#.#.#########.#
#...#...#.....#.#.....#.#.#.....###...#.#.....#.......#...###...#.#.#.#.#.>.>.#...#...#.#.#.#...#.###.#.....#.#.#...#.#.#.#.#.#.#.#.........#
#.###.#######.#.#####.#.#.###########.#.#####.#.###############.#.#.#.#.#.#v#.#.###.###.#.#.#.###.###.#.#####.#.#.#.#.#.#.#.#.#.#.#.#########
#...#.........#.....#.#.#.#...........#.###...#.......###.......#.#.#.#...#.#.#...#.#...#...#...#.#...#.#...#.#.#.#.#.#.#.#.#.#.#.#.#...#...#
###.###############.#.#.#.#.###########.###.#########.###.#######.#.#.#####.#.###.#.#.#########.#.#.###.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#
###...............#.#.#.#.#...#.......#...#.#...#...#...#...#...#.#...###...#.....#...#...#.....#.#...#.#.#.#.#.#.#.#.#.#.#.#.#.#.#...#.#.#.#
#################.#.#.#.#.###.#.#####.###.#.#.#.#.#.###.###.#.#.#.#######.#############.#.#.#####.###.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#####.#.#.#
#.................#...#...###.#.#.....#...#...#.#.#.#...###...#.#.#.......#...#...#.....#.#.#.....#...#...#...#.#.#...#.#.#...#...#...#...#.#
#.###########################.#.#.#####.#######.#.#.#.#########.#.#.#######.#.#.#.#.#####.#.#.#####.###########.#.#####.#.#########.#.#####.#
#.................###...#####...#.....#.#.......#.#...#...#.....#.#...#...#.#...#.#.#.....#...#.....#...###...#.#.....#...###...#...#.#...#.#
#################.###.#.#############.#.#.#######.#####.#.#.#####.###.#.#.#.#####.#.#.#########.#####.#.###.#.#.#####.#######.#.#.###.#.#.#.#
#.......#...#...#.#...#...#...#.....#...#.....###.....#.#.#.....#...#...#.#.#.....#.#.#.....#...#...#.#...#.#.#.......#...#...#.#.###...#...#
#.#####.#.#.#.#.#.#.#####.#.#.#.###.#########.#######.#.#.#####.###.#####.#.#.#####.#.#.###.#.###.#.#.###.#.#.#########.#.#.###.#.###########
#.#...#...#...#...#.#.....#.#.#...#.###.......#.......#.#...###.....###...#.#.#.....#.#.#...#.....#...###...#...###...#.#.#...#.#...........#
#.#.#.#############.#.#####.#.###.#.###.#######.#######.###.###########.###.#.#.#####.#.#.#####################.###.#.#.#.###.#.###########.#
#...#.#...#...#...#.#...#...#...#.#.....#.....#...#...#.#...#.........#.....#.#.#.....#.#.#...#.......#.........#...#.#.#.#...#...#.......#.#
#####.#.#.#.#.#.#.#.###.#.#####.#.#######.###.###.#.#.#.#.###.#######.#######.#.#.#####.#.#.#.#.#####.#.#########.###.#.#.#.#####.#.#####.#.#
#.....#.#.#.#.#.#.#...#.#.#.....#...#...#.#...###...#...#.#...#.......###...#...#...#...#.#.#.#...#...#.#.......#...#...#...#####...#...#.#.#
#.#####.#.#.#v#.#.###.#.#.#.#######.#.#.#.#.#############.#.###.#########.#.#######.#.###.#.#.###.#.###.#.#####.###.#################.#.#.#.#
#.......#...#.>.#...#.#.#.#...#...#...#...#.###...###.....#...#.#...#.....#.#.......#...#.#.#.....#...#...#...#...#.#...............#.#.#...#
#############v#####.#.#.#.###.#.#.#########.###.#.###v#######.#.#.#.#.#####.#.#########.#.#.#########.#####.#.###.#.#.#############.#.#.#####
#.........###.....#...#...#...#.#.......#...#...#.#.>.>.#...#.#.#.#.#.....#.#.#...#...#.#.#.......#...#...#.#...#.#.#.#.............#.#.....#
#.#######.#######.#########.###.#######.#.###.###.#.#v#.#.#.#.#.#.#.#####.#.#.#.#.#.#.#.#.#######.#.###.#.#v###.#.#.#.#.#############.#####.#
#.......#.#.....#.....#.....###.......#.#...#...#...#.#.#.#.#.#.#.#...###.#.#...#.#.#.#.#...#...#.#...#.#.>.>.#...#...#...............#...#.#
#######.#.#.###.#####.#.#############.#.###v###.#####.#.#.#.#.#.#.###.###.#.#####v#.#.#.###.#.#.#.###.#.###v#.#########################.#.#.#
#...###.#.#...#.#.....#.#.....#...#...#.#.>.>...#.....#...#.#.#...###...#.#.#...>.>.#...###.#.#.#.#...#.#...#.#...#...#...#.........#...#.#.#
#.#.###.#.###.#.#.#####.#.###.#.#.#.###.#.#v#####.#########.#.#########.#.#.#.###v#########.#.#.#.#.###.#.###.#.#.#.#.#.#.#v#######.#.###.#.#
#.#...#.#.###.#.#.....#.#.###.#.#...###...#.....#...#...###...#.......#.#.#.#...#.#...#...#.#.#.#.#.#...#.###.#.#.#.#.#.#.>.###...#...###...#
#.###.#.#.###.#.#####.#.#.###.#.###############.###.#.#.#######.#####.#.#.#.###.#.#.#.#.#.#.#.#.#.#.#.###.###.#.#.#.#.#.###v###.#.###########
#...#.#.#...#.#.......#.#.#...#.###...###...#...###...#.........#.....#...#.....#...#...#.#.#.#.#.#.#.###...#...#.#.#.#.###.....#.#...#...###
###.#.#.###.#.#########.#.#.###.###.#.###.#.#.###################.#######################.#.#.#.#.#.#.#####.#####.#.#.#.#########.#.#.#.#.###
#...#.#...#.#.#.......#.#.#...#.#...#.#...#.#.#.................#.....#.................#.#...#...#...#.....#...#...#...#.........#.#...#...#
#.###.###.#.#.#.#####.#.#.###.#.#.###.#.###.#.#.###############.#####.#.###############.#.#############.#####.#.#########.#########.#######.#
#...#.....#...#.#.....#...#...#.#...#...###...#...#...#.......#.#.....#...........#...#...#...###.....#.....#.#.###...###.........#.#.......#
###.###########.#.#########.###.###.#############.#.#.#.#####.#.#.###############.#.#.#####.#.###.###.#####.#.#.###.#.###########.#.#.#######
###.............#.....#...#.....###...#...###...#...#...#.....#...#...#...#...###...#...#...#...#...#.#.....#.#.#...#...#.........#.#.#...###
#####################.#.#.###########.#.#.###.#.#########.#########.#.#.#.#.#.#########.#.#####.###.#.#.#####.#.#.#####.#.#########.#.#.#.###
#.....................#.#.#.....#...#...#.....#.#...#.....###...###.#.#.#.#.#.#...#.....#.....#.###.#.#...###.#.#...#...#.........#.#...#...#
#.#####################.#.#.###.#.#.###########.#.#.#.#######.#.###.#.#.#.#.#.#.#.#.#########.#.###.#.###v###.#.###.#.###########v#.#######.#
#.#.....#.............#.#.#...#.#.#.............#.#.#.......#.#.###.#.#.#.#.#.#.#.#...#####...#.#...#...>.>.#.#.#...#...#.....#.>.#.#.......#
#.#.###.#.###########.#.#.###.#.#v###############.#.#######.#.#.###.#.#.#.#.#.#.#.###v#####.###.#.#######v#.#.#.#.#####.#.###.#.#v#.#.#######
#...#...#.#.....#...#.#.#.#...#.>.>...#...###.....#...#.....#.#.###.#.#.#.#.#.#.#...>.>.#...###.#.#.......#...#...#.....#...#...#.#.#.#...###
#####.###.#.###.#.#.#.#.#.#.#####v###.#.#.###.#######.#.#####.#.###.#.#.#.#.#.#.#####v#.#.#####.#.#.###############.#######.#####.#.#.#.#.###
#...#.....#...#...#...#.#...###...###...#...#.#.......#.....#.#.#...#.#.#.#.#.#...#...#...#...#...#.....#...###.....#...#...#.....#.#...#...#
#.#.#########.#########.#######.###########.#.#.###########.#.#.#.###.#.#.#.#.###.#.#######.#.#########.#.#.###.#####.#.#.###.#####.#######.#
#.#.#...#...#...#.....#.......#.......#...#...#...###...#...#.#.#...#.#.#.#.#.#...#.........#.#...#####...#...#...#...#...###.......#...#...#
#.#.#.#.#.#.###.#.###.#######.#######.#.#.#######.###.#.#v###.#.###.#.#.#.#.#.#.#############.#.#.###########.###.#.#################.#.#.###
#.#...#...#.....#.#...#...#...#.......#.#.......#...#.#.>.>...#.#...#.#.#.#.#.#...###.......#.#.#.............#...#.#.................#...###
#.###############.#.###.#.#.###.#######.#######.###.#.###v#####.#.###.#.#.#.#.###.###.#####.#.#.###############.###.#.#######################
#...#.....#...###.#.....#...###...#...#...#.....#...#...#.#...#...###...#...#.#...#...#...#...#.............###.#...#.......................#
###.#.###.#.#v###.###############.#.#.###.#.#####.#####.#.#.#.###############.#.###.###.#.#################.###.#.#########################.#
###.#.###.#.#.>...#...........#...#.#.....#.#...#...#...#.#.#.........#.......#.###.....#.#.......#.......#...#.#.#...###...#...............#
###.#.###.#.#v#####.#########.#.###.#######.#.#.###.#.###.#.#########.#.#######.#########.#.#####.#.#####.###.#.#.#.#.###.#.#.###############
#...#...#...#...#...#.........#.....#.......#.#...#.#.###.#.#.....#...#.......#...#.......#.#.....#.....#.....#...#.#.....#...#...#...###...#
#.#####.#######.#.###.###############.#######.###.#.#.###.#.#.###.#.#########.###.#.#######.#.#########.###########.###########.#.#.#.###.#.#
#.#.....#.....#...#...#...#...#...###.........#...#.#.###...#...#...#####...#.....#.........#...###...#.........###.....#.....#.#...#.#...#.#
#.#.#####.###.#####.###.#.#.#.#.#.#############.###.#.#########.#########.#.###################.###.#.#########.#######.#.###.#.#####.#.###.#
#...#...#...#.......###.#.#.#.#.#...#...........###...#...#...#...#...###.#.###.......#.........#...#.#.........#...###...###...#.....#.#...#
#####.#.###.###########.#.#.#.#.###.#.#################.#.#.#.###.#.#.###.#.###.#####.#.#########.###.#.#########.#.#############.#####.#.###
#.....#.....#.........#.#...#.#...#.#...#...#...###...#.#.#.#.###...#.....#...#.....#.#.........#...#.#.....#.....#.#...###...#...#.....#.###
#.###########.#######.#.#####.###.#.###.#.#.#.#.###.#.#.#.#.#.###############.#####.#.#########.###.#.#####.#.#####.#.#.###.#.#.###.#####.###
#.......#...#.#.......#.....#...#.#.###...#...#...#.#.#.#.#.#...#.....#.....#.#.....#...........###.#.......#.#.....#.#.#...#.#.....#...#...#
#######.#.#.#.#.###########.###.#.#.#############.#.#.#.#.#.###.#.###.#.###.#.#.###################.#########.#.#####.#.#.###.#######.#.###.#
#.......#.#...#.........#...#...#.#.#...###.......#.#.#.#.#.#...#.###...###...#.......#...###.....#.....#...#.#.#...#.#.#.#...#...###.#.#...#
#.#######.#############.#.###.###.#.#.#.###v#######.#.#.#.#.#.###v###################.#.#.###.###.#####v#.#.#.#.#.#.#.#.#.#.###.#.###.#.#v###
#.......#.#.............#...#...#.#.#.#...>.>...#...#.#.#...#...>.>.#...#...###.......#.#...#...#.#...>.>.#.#.#.#.#.#.#.#.#...#.#.....#.>.###
#######.#.#.###############.###.#.#.#.#####v###.#.###.#.#########v#.#.#.#.#.###.#######.###.###.#.#.###v###.#.#.#.#.#.#.#.###.#.#########v###
###...#...#.........###...#...#...#...###...#...#.#...#...#...#...#...#...#...#.........#...###.#.#...#...#.#.#.#.#.#.#.#.#...#.#...###...###
###.#.#############.###.#.###.###########.###.###.#.#####.#.#.#.#############.###########.#####.#.###.###.#.#.#.#.#.#.#.#.#.###.#.#.###.#####
#...#...............#...#.#...#...........###...#.#.#.....#.#.#...#...........#...#.......###...#.#...#...#.#.#.#.#.#.#.#.#.....#.#...#.#...#
#.###################.###.#.###.###############.#.#.#.#####.#.###.#.###########.#.#.#########.###.#.###.###.#.#.#.#.#.#.#.#######.###.#.#.#.#
#.#...........#...#...#...#...#.............#...#.#...###...#.#...#...###...#...#.#.........#...#.#.###...#...#...#...#...#.....#.#...#...#.#
#.#.#########.#.#v#.###.#####.#############.#.###.#######.###.#.#####.###.#.#.###.#########.###.#.#.#####.#################.###.#.#.#######.#
#.#.###...###...#.>.###.......#...###.......#.....###...#...#.#.....#...#.#.#.#...#...###...#...#.#...#...#...#...#...#...#...#...#...#...#.#
#.#.###.#.#######v#############.#.###.###############.#.###.#.#####.###.#.#.#.#.###.#.###v###.###.###.#.###.#.#.#.#.#.#.#.###.#######.#.#.#.#
#...#...#.......#.........#.....#.....#...###...###...#.....#.#.....#...#.#.#.#...#.#...>.>.#...#.....#.....#.#.#...#...#.###.......#.#.#.#.#
#####.#########.#########.#.###########.#.###.#.###.#########.#.#####.###.#.#.###.#.#####v#.###.#############.#.#########.#########.#.#.#.#.#
#.....#.......#.#...#...#.#.............#.....#.#...#...#...#.#...#...#...#...#...#...#...#.#...###...........#.........#.#...#...#.#.#.#...#
#.#####.#####.#.#.#.#.#.#.#####################.#.###.#.#.#.#.###.#.###.#######.#####.#.###.#.#####.###################.#.#.#.#.#.#.#.#.#####
#.#.....#.....#...#...#...#.......#.............#.....#...#.#.....#...#.......#.....#.#...#.#.....#.............#.......#...#...#.#.#.#.....#
#.#.#####.#################.#####.#.#######################.#########.#######.#####.#.###.#.#####.#############.#.###############.#.#.#####.#
#...#...#.#...#.......#...#...#...#...........#.......#...#.#...#...#.#.......#.....#.#...#.......#.......#.....#...#...#...#...#...#.......#
#####.#.#.#.#.#.#####.#.#.###.#.#############.#.#####.#.#.#.#.#.#.#.#.#.#######.#####.#.###########.#####.#.#######.#.#.#.#.#.#.#############
#...#.#.#...#...#.....#.#.#...#...###...#.....#.....#...#...#.#.#.#.#...#...###.......#.#...#.....#.#...#...###...#.#.#.#.#...#.###.........#
#.#.#.#.#########.#####.#.#.#####.###.#.#.#########.#########.#.#.#.#####.#.###########.#.#.#.###.#.#.#.#######.#.#.#.#.#.#####.###.#######.#
#.#...#.#...#...#.....#.#.#...#...#...#...###.....#...#...###.#.#.#.#...#.#.###...#...#.#.#.#.#...#.#.#.......#.#.#...#...#...#.....#...#...#
#.#####.#.#.#.#.#####.#.#.###.#.###.#########.###.###.#.#.###.#.#.#.#.#.#.#.###.#.#.#.#v#.#.#.#.###.#.#######.#.#.#########.#.#######.#.#.###
#.....#.#.#...#.#.....#.#...#.#.###...###...#...#.###.#.#.#...#.#.#.#.#.#.#.#...#.#.#.>.>.#...#.###...#.......#.#.#.........#.........#...###
#####.#.#.#####.#.#####.###.#.#.#####v###.#.###.#.###v#.#.#.###.#.#.#.#.#.#.#.###.#.###v#######.#######.#######.#.#.#########################
#.....#...#...#...#...#...#.#.#.#...>.>...#.#...#...>.>.#.#...#.#.#.#.#.#.#.#...#.#.#...#.....#...#.....#.....#.#.#.........#.........#.....#
#.#########.#.#####.#.###.#.#.#.#.###v#####.#.#######v###.###.#.#.#.#.#.#.#.###.#.#.#.###.###.###.#.#####.###.#.#.#########.#.#######.#.###.#
#.....#.....#.....#.#...#.#.#.#.#...#...###...###...#...#...#.#.#.#.#.#.#.#.#...#...#...#...#.....#.......#...#.#...#...###.#.#.......#...#.#
#####.#.#########.#.###.#.#.#.#.###.###.#########.#.###.###.#.#.#.#.#.#.#.#.#.#########.###.###############.###.###.#.#.###.#.#.#########.#.#
#.....#.#.........#...#.#.#.#.#.#...###.......#...#.#...###.#.#.#.#.#.#.#.#.#.#...#.....###.........#.......#...#...#.#...#...#...#.......#.#
#.#####.#.###########.#.#.#.#.#.#.###########.#.###.#.#####.#.#.#.#.#.#.#.#.#.#.#.#.###############.#.#######.###.###.###.#######.#.#######.#
#...#...#.........#...#.#.#.#.#...#...........#...#...#...#.#.#.#.#.#.#...#.#.#.#.#.....#####.......#...#...#...#.###.#...#.....#...#...#...#
###.#.###########.#.###.#.#.#.#####.#############.#####.#.#.#.#.#.#.#.#####.#.#.#.#####.#####.#########v#.#.###.#.###.#.###v###.#####.#.#.###
###...#...###...#.#...#...#...###...#...#.......#.......#.#...#.#.#.#...#...#.#.#.......#.....#.......>.>.#.#...#...#.#...>.###.......#...###
#######.#.###.#.#v###.###########.###.#.#.#####.#########.#####.#.#.###.#.###.#.#########.#####.#######v###.#.#####.#.#####v#################
#.......#.....#.#.>.#.......#...#.....#...#.....#.........#...#...#.#...#.#...#...#...###.#...#.....###...#.#.....#.#...#...###...#...#.....#
#.#############.#v#.#######.#.#.###########.#####.#########.#.#####.#.###.#.#####.#.#.###.#.#.#####.#####.#.#####.#.###.#.#####.#.#.#.#.###.#
#.............#...#.......#.#.#...........#...###.......#...#...###...###.#...###...#...#...#.#.....#...#.#.#...#.#.#...#.#...#.#...#.#.#...#
#############.###########.#.#.###########.###.#########.#.#####.#########.###.#########.#####.#.#####.#.#.#.#.#.#.#.#.###.#.#.#.#####.#.#.###
#...#...#...#...........#.#.#...#.......#.....#...###...#.#.....#...#...#.#...#.........#...#.#.#.....#...#.#.#...#.#...#.#.#.#.#.....#.#...#
#.#.#.#.#.#.###########.#.#.###.#.#####.#######.#.###.###.#.#####.#.#.#.#.#.###.#########.#.#.#.#.#########.#.#####.###.#.#.#.#.#.#####.###.#
#.#...#...#.......#.....#...###...#...#...#.....#.#...###.#.#...#.#...#.#...###...........#.#.#.#.....#...#.#...#...#...#...#.#.#.#...#.#...#
#.###############.#.###############.#.###.#.#####.#.#####.#.#.#.#.#####.###################.#.#.#####.#.#.#.###.#.###.#######.#.#.#.#.#.#.###
#...............#.#.......#...#.....#.....#.#.....#.......#.#.#.#...#...###.................#...#...#...#.#.#...#...#.....#...#.#.#.#...#...#
###############.#.#######.#.#.#.###########.#.#############.#.#.###.#.#####.#####################.#.#####.#.#.#####.#####.#.###.#.#.#######.#
#...............#.#.....#...#.#.............#.....#.......#.#.#.###.#.#...#.......#...........#...#.....#.#...#.....#.....#.....#...###.....#
#.###############.#.###.#####.###################.#.#####.#.#.#.###.#.#.#.#######.#.#########.#.#######.#.#####.#####.#################.#####
#.......#...#...#...###.......###...#.............#.....#...#.#...#.#...#.###...#...#.........#.......#...#...#.......###...#...#.......#...#
#######.#.#.#.#.#################.#.#.#################.#####.###.#.#####.###.#.#####.###############.#####.#.###########.#.#.#.#.#######.#.#
#...###...#...#.....#...#...#.....#.#.........#...#.....#...#.#...#.#.....#...#.......###...###...###...#...#...#...#.....#.#.#.#.....#...#.#
#.#.###############.#.#.#.#.#.#####.#########.#.#.#.#####.#.#.#.###.#.#####.#############.#.###.#.#####.#.#####.#.#.#.#####.#.#.#####.#.###.#
#.#.................#.#.#.#.#.#.....#.........#.#.#...###.#.#.#.#...#.#...#.......#.....#.#.#...#.......#.#.....#.#.#.#.....#.#...###...#...#
#.###################.#.#.#.#.#.#####.#########.#.###.###.#.#.#.#.###.#.#.#######.#.###.#.#.#.###########.#.#####.#.#.#.#####.###.#######.###
#.#...#...#.....#...#.#.#.#.#.#.#...#.......#...#...#...#.#.#.#.#...#.#.#.###...#...#...#.#.#.....#.......#.....#.#.#.#.....#...#.#.....#...#
#.#.#.#.#.#.###.#.#.#.#.#.#.#.#.#.#.#######.#.#####.###.#.#.#.#.###.#.#.#.###.#.#####v###.#.#####.#.###########.#.#.#.#####.###.#.#.###.###.#
#...#...#.#.#...#.#.#.#.#.#.#.#.#.#.###.....#...#...#...#.#.#.#...#.#.#.#...#.#.#...>.>.#.#.#...#...#...........#.#.#.#.....###.#.#.#...#...#
#########.#.#.###.#.#.#.#.#.#.#.#.#.###v#######.#.###v###.#.#.###.#.#.#.###.#.#.#.#####.#.#.#.#.#####v###########.#.#.#.#######.#.#.#.###v###
#.........#.#...#.#...#.#.#.#.#.#.#...>.>...#...#.#.>.>.#.#.#...#.#.#.#...#...#.#...###.#.#...#.#...>.>.#...#...#.#.#.#.#...#...#...#.#.>.###
#.#########.###.#.#####.#.#.#.#.#.#########.#.###.#.###.#.#.###.#.#.#.###.#####.###.###.#.#####.#.#####.#.#.#.#.#.#.#.#.#.#.#.#######.#.#v###
#.....#...#.#...#.#.....#.#.#.#.#.#.........#...#.#...#.#.#.#...#.#.#.#...#.....#...#...#.....#.#...#...#.#.#.#.#.#.#.#.#.#.#.#.......#.#.###
#####.#.#.#.#.###.#.#####.#.#.#.#.#.###########.#.###.#.#.#.#.###.#.#.#.###.#####.###.#######.#.###.#.###.#.#.#.#.#.#.#.#.#.#.#.#######.#.###
#####...#...#.....#.......#...#...#.............#.....#...#...###...#...###.......###.........#.....#.....#...#...#...#...#...#.........#...#
###########################################################################################################################################.#

23
day23/sample.txt Normal file
View File

@@ -0,0 +1,23 @@
#.#####################
#.......#########...###
#######.#########.#.###
###.....#.>.>.###.#.###
###v#####.#v#.###.#.###
###.>...#.#.#.....#...#
###v###.#.#.#########.#
###...#.#.#.......#...#
#####.#.#.#######.#.###
#.....#.#.#.......#...#
#.#####.#.#.#########v#
#.#...#...#...###...>.#
#.#.#v#######v###.###v#
#...#.>.#...>.>.#.###.#
#####v#.#.###v#.#.###.#
#.....#...#...#.#.#...#
#.#########.###.#.#.###
#...###...#...#...#.###
###.###.#.###v#####v###
#...#...#.#.>.>.#.>.###
#.###.###.#.###.#.#v###
#.....###...###...#...#
#####################.#