From 3420ee5b3ab92eeb4f33b511ebe5f3f74ff91705 Mon Sep 17 00:00:00 2001 From: dobiadi Date: Fri, 20 Dec 2024 20:14:32 +0100 Subject: [PATCH] Day20 --- day20/c/day20 | Bin 0 -> 15720 bytes day20/c/day20.c | 220 +++++++++++++++++++++++++++++++++++++++++++++++ day20/input.txt | 141 ++++++++++++++++++++++++++++++ day20/sample.txt | 15 ++++ 4 files changed, 376 insertions(+) create mode 100755 day20/c/day20 create mode 100644 day20/c/day20.c create mode 100644 day20/input.txt create mode 100644 day20/sample.txt diff --git a/day20/c/day20 b/day20/c/day20 new file mode 100755 index 0000000000000000000000000000000000000000..d7394719a1ac4731437a4fbd0cf32fd4b666e8e0 GIT binary patch literal 15720 zcmeHOe{dVeb>1T(39==CQYD+Q6&n*n3Ds5*AWNjx5>oi@{Prk+X0ZD!ImY4f9XK*=N}*YQw_t#YI&W}T=7L&cJ< z*rMH9==bjS!5~6;+Wyf=X0X!T+xP8z``*5NcejUIemWG{)u1SXOQZNhL0s3Z77~yR zrLD385)f@-CC+z<4~nJWZ6;>52P}eCt4ud6q;`onf|6b{RTiP^ELbpQ4~dfAjY`)t ztA(j(vUt*4LRHDv(g&ntOu4;c&qc~8F7sTWYe)cvX|*23W@@9^ET(oWq`fjOBa*Tn zv7|R6^=71Ag-Uxfl5#vLCUmsPc-GPY+NcD~vkxg7?lReb34hd!9igs{bi%~EqUqQ z#InabWA6+;w(mcl?0xz>BtzpM9g?9!7#&>5{hM)+j1?c37(ty1;YSX{I20yUd!ox_ zbu9>f)eZ1o;4U1sB>-Tte*8DUDT<59j{4Uk4(sC;A3OPb!%dN0NG6M5D-ncr>lYQhIbChPG%lJ{*ho^bN-P`yNh;c&xvF zC@uz)1L>qLj;8ts^&UYwlqB24?nt;}XLPe?OKYXN*|Swd!`+?HL^72;(wEkgsqW65 z{X>Jv?%3h}Bn%uG7#fr&qn7BRf^fY7nWNxL|B!34MtRU6cB7pq{o9X!8EMfd?v+^P zwmzg}gE(Xjz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SG|LAXQ(gziW>c2yMDM~u&tBGVlln{pXsa%~o?vVnD%JYKQlBaPUR+)He#BT9 zm1_O3NPVU*7L>GB|9;^3iF%0r=k*O!w$JOETK{9vr{9-ZpVvQ3T@+jt@{y{n&+8C+ z?vTr@&+93syncd+S!8$2icg?MYZcb#^$An9!~U}z(?_9CYaix${lk=>?X~{10|itl zrmWBFFQ&ZyV*9n@r{^Wp7;w7HoERE9$lSUj;@n;r=W4cX^-Zb*}8jw8eFz zU%^qW?~-~WSK~qS@8qZ$Uf@_qySUSe^#iqf2u~mSL!qUTUL~m=a1nZqvF6JFWbuBE%D#= z)ygx^l-6g?Dt&%`ncfHxh2<>nJ)ZG7G*IraeO`A~{!WvEgTm9udOVN6LK}&&KL5Q` zaT93?(PELxne~~{I;>is-+xL{KTy%MDy+wpc9>P`^ZKvFYss^p+zsnhcqkLb{s#h9 zOWO_fYx`R%?Mrd)RVDxN~M}|?pZC?`Kau0N;cASh~|m?=lj}nVC=i4X`KUG cEcyjDBpYj3tT`9ge~~^?qTEuWP{WG<2C2%1^Z)<= literal 0 HcmV?d00001 diff --git a/day20/c/day20.c b/day20/c/day20.c new file mode 100644 index 0000000..9cce81f --- /dev/null +++ b/day20/c/day20.c @@ -0,0 +1,220 @@ +#include +#include +#include +#include +#include + +#define MAX_DIMENSION 1024 +#define QUEUE_MAX 32*1024 +#define abs(a) ((a) < 0 ? (-(a)) : (a)) + +const int directions[][2] = { + {0, 1}, + {1, 0}, + {0, -1}, + {-1, 0} +}; + +#define directions_len (sizeof(directions)/sizeof(directions[0])) + +typedef enum tile { + EMPTY, + WALL, +} tile_t; + +int ospf(tile_t **map, int rows, int colums, int start[2], int end[2]); + +int main() { + char c; + + tile_t **map = calloc(MAX_DIMENSION, sizeof(map[0])); + int rows = 0, columns, i = 0; + map[0] = calloc(MAX_DIMENSION, sizeof(map[0][0])); + + int start[2], end[2]; + while ((c = getchar()) != EOF) { + switch(c) { + case '#': + map[rows][i] = WALL; + break; + case '.': + map[rows][i] = EMPTY; + break; + case 'S': + map[rows][i] = EMPTY; + start[0] = rows; + start[1] = i; + break; + case 'E': + map[rows][i] = EMPTY; + end[0] = rows; + end[1] = i; + break; + } + + i++; + if (c != '\n') { + continue; + } + + columns = i - 1; + i = 0; + rows++; + map[rows] = calloc(MAX_DIMENSION, sizeof(map[0][0])); + } + + int without_cheats = 0; + + // Shortest path search + uint32_t **costs = calloc(rows, sizeof(costs[0])); + for (int i = 0; i < rows; i++) { + costs[i] = calloc(columns, sizeof(costs[0][0])); + memset(costs[i], 255, columns * sizeof(costs[0][0])); + } + + int (*queue)[2] = calloc(QUEUE_MAX, sizeof(queue[0])); + int queue_num = 1; + // Start at 0,0 + queue[0][0] = start[0]; + queue[0][1] = start[1]; + costs[start[0]][start[1]] = 0; + + while (queue_num > 0) { + // Pop first + int x = queue[0][0]; + int y = queue[0][1]; + uint32_t cost = costs[x][y]; + + if (x == end[0] && y == end[1]) { + without_cheats = cost; + break; + } + + for (int i = 0; i < queue_num - 1; i++) { + queue[i][0] = queue[i+1][0]; + queue[i][1] = queue[i+1][1]; + } + queue_num--; + + // Check each direction + for (int i = 0; i < directions_len; i++) { + int dx = directions[i][0]; + int dy = directions[i][1]; + + int next_x = x + dx; + int next_y = y + dy; + + // Outside of map, into wall, or better path exists + if (next_x < 0 || next_y < 0 || next_x >= rows || next_y >= columns || map[next_x][next_y] || costs[next_x][next_y] <= cost + 1) { + continue; + } + + // Insert into queue + uint32_t next_cost = cost + 1; + costs[next_x][next_y] = next_cost; + int insert_idx; + for (insert_idx = 0; insert_idx < queue_num; insert_idx++) { + int qx = queue[insert_idx][0]; + int qy = queue[insert_idx][1]; + if (costs[qx][qy] > next_cost) { + break; + } + } + + for (int j = queue_num; j > insert_idx; j--) { + queue[j][0] = queue[j-1][0]; + queue[j][1] = queue[j-1][1]; + } + queue[insert_idx][0] = next_x; + queue[insert_idx][1] = next_y; + queue_num++; + } + } + + int good_cheats = 0; + int good_cheat_limit = 100; + + // Find where to cheat + for (i = 0; i < rows; i++) { + for (int j = 0; j < columns; j++) { + if (map[i][j] != EMPTY) { + continue; + } + // Try each direction and check if there's a wall + for (int k = 0; k < directions_len; k++) { + int dx = directions[k][0]; + int dy = directions[k][1]; + int x = i + dx; + int y = j + dy; + + if (x < 0 || y < 0 || x >= rows || y >= columns || map[x][y] != WALL) { + continue; + } + + // Now check whether we can get back to the track to shorten out time + for (int l = 0; l < directions_len; l++) { + int dx = directions[l][0]; + int dy = directions[l][1]; + int xx = x + dx; + int yy = y + dy; + + if (xx < 0 || yy < 0 || xx >= rows || yy >= columns || map[xx][yy] == WALL) { + continue; + } + + // Not good cheat enough + if (costs[xx][yy] < costs[i][j] + good_cheat_limit + 2) { + continue; + } + + good_cheats++; + } + } + } + } + + int good_cheats2 = 0; + int good_cheat_limit2 = 100; + + // Find where to cheat + for (i = 0; i < rows; i++) { + for (int j = 0; j < columns; j++) { + if (map[i][j] != EMPTY) { + continue; + } + + // Check submap, we can get to anywhere inside a 20 radius "circle" by activating the cheat here + for (int k = i-20; k <= i+20; k++) { + for (int l = j-(20-abs(k-i)); l <= j+(20-abs(k-i)); l++) { + if (k < 0 || l < 0 || k >= rows || l >= columns) { + continue; + } + + // We don't want to get into a wall + if (map[k][l] == WALL) { + continue; + } + + // Not good cheat enough + if (costs[k][l] < costs[i][j] + good_cheat_limit2 + abs(k-i) + abs(l-j)) { + continue; + } + + good_cheats2++; + } + } + } + } + + printf("%i\n", good_cheats); + printf("%i\n", good_cheats2); + + for (i = 0; i < rows; i++) { + free(costs[i]); + } + free(costs); + for (i = 0; i < rows + 1; i++) { + free(map[i]); + } + free(map); +} diff --git a/day20/input.txt b/day20/input.txt new file mode 100644 index 0000000..21b2fed --- /dev/null +++ b/day20/input.txt @@ -0,0 +1,141 @@ +############################################################################################################################################# +#.......#...#.......#...#...###.....#.....#.....#.....#.....#...###...###.............#...#...#.......#...#...#...#...#...#.........#...#...# +#.#####.#.#.#.#####.#.#.#.#.###.###.#.###.#.###.#.###.#.###.#.#.###.#.###.###########.#.#.#.#.#.#####.#.#.#.#.#.#.#.#.#.#.#.#######.#.#.#.#.# +#.....#.#.#.#.....#...#...#...#...#.#...#.#...#.#.#...#...#.#.#.#...#...#.......#.....#.#.#.#.#...#...#.#.#.#.#.#...#...#...#.....#...#...#.# +#####.#.#.#.#####.###########.###.#.###.#.###.#.#.#.#####.#.#.#.#.#####.#######.#.#####.#.#.#.###.#.###.#.#.#.#.#############.###.#########.# +#.....#.#.#.#.....#...#...#...#...#.....#...#.#.#.#.#...#.#.#.#.#.#...#.....#...#.#...#.#...#.###.#.#...#...#.#.#.............###.....#...#.# +#.#####.#.#.#.#####.#.#.#.#.###.###########.#.#.#.#.#.#.#.#.#.#.#.#.#.#####.#.###.#.#.#.#####.###.#.#.#######.#.#.###################.#.#.#.# +#.....#...#.#.......#.#.#...###.........#...#.#...#.#.#.#.#.#.#.#...#.....#.#...#...#.#.#.....#...#...#.......#.#.......###...#.....#...#...# +#####.#####.#########.#.###############.#.###.#####.#.#.#.#.#.#.#########.#.###.#####.#.#.#####.#######.#######.#######.###.#.#.###.######### +#.....#...#.....#...#.#...#...#.........#.#...#...#.#.#...#...#...#.......#...#...#...#.#.....#.#.....#.....###.#.......#...#...#...###...### +#.#####.#.#####.#.#.#.###.#.#.#.#########.#.###.#.#.#.###########.#.#########.###.#.###.#####.#.#.###.#####.###.#.#######.#######.#####.#.### +#.......#.....#...#...#...#.#.#.........#.#.#...#...#...#.........#.#.......#.....#.#...#.....#...###.....#...#.#.#.......#...#...#...#.#...# +#############.#########.###.#.#########.#.#.#.#########.#.#########.#.#####.#######.#.###.###############.###.#.#.#.#######.#.#.###.#.#.###.# +###...###...#.........#...#.#...#.....#.#...#.###...#...#.........#...#...#...#.....#...#.#.......#...#...#...#.#...#...#...#...###.#.#.#...# +###.#.###.#.#########.###.#.###.#.###.#.#####.###.#.#.###########.#####.#.###.#.#######.#.#.#####.#.#.#.###.###.#####.#.#.#########.#.#.#.### +#...#.#...#.........#.#...#...#.#...#...#...#.....#.#.....#.......###...#.....#.....###.#.#.#...#.#.#.#...#.#...#.....#...#.....#...#...#...# +#.###.#.###########.#.#.#####.#.###.#####.#.#######.#####.#.#########.#############.###.#.#.#.#.#.#.#.###.#.#.###.#########.###.#.#########.# +#...#...#.........#...#.......#...#...#...#...#.....#...#.#.....#...#.........#.....#...#.#.#.#...#.#.#...#...#...#...#...#...#.#.#.........# +###.#####.#######.###############.###.#.#####.#.#####.#.#.#####.#.#.#########.#.#####.###.#.#.#####.#.#.#######.###.#.#.#.###.#.#.#.######### +#...#...#.#.......#...........#...#...#.#.....#.....#.#.#.#.....#.#.#...#.....#...#...#...#.#...###.#.#.#.....#.....#...#...#.#...#.......### +#.###.#.#.#.#######.#########.#.###.###.#.#########.#.#.#.#.#####.#.#.#.#.#######.#.###.###.###.###.#.#.#.###.#############.#.###########.### +#.....#...#.........#.....###.#...#.....#.......#...#.#...#.#...#.#.#.#.#.......#.#...#.###.#...#...#.#.#...#.............#...#...#.....#...# +#####################.###.###.###.#############.#.###.#####.#.#.#.#.#.#.#######.#.###.#.###.#.###.###.#.###.#############.#####.#.#.###.###.# +#.......#...#...#...#...#.#...#...#...###.......#.###...#...#.#.#.#.#.#...#...#.#.#...#...#.#.#...#...#.#...#...........#.#...#.#.#...#...#.# +#.#####.#.#.#.#.#.#.###.#.#.###.###.#.###.#######.#####.#.###.#.#.#.#.###.#.#.#.#.#.#####.#.#.#.###.###.#.###.#########.#.#.#.#.#.###.###.#.# +#.....#...#.#.#...#.....#.#.#...###.#...#.......#.#.....#.....#...#.#...#.#.#.#.#.#.#.....#.#.#...#.#...#.....#.........#...#...#.#...###...# +#####.#####.#.###########.#.#.#####.###.#######.#.#.###############.###.#.#.#.#.#.#.#.#####.#.###.#.#.#########.#################.#.######### +#...#.....#.#.......#...#...#.....#...#...#...#.#.#.......#.........#...#.#.#...#.#.#...###.#...#.#.#...#.......###...#.........#...###.....# +#.#.#####.#.#######.#.#.#########.###.###.#.#.#.#.#######.#.#########.###.#.#####.#.###.###.###.#.#.###.#.#########.#.#.#######.#######.###.# +#.#.......#.......#...#...#...#...###...#.#.#.#.#.#...###.#...#...###.#...#.#...#...#...#...#...#.#.....#.#...#.....#...#.....#.###...#...#.# +#.###############.#######.#.#.#.#######.#.#.#.#.#.#.#.###.###.#.#.###.#.###.#.#.#####.###.###.###.#######.#.#.#.#########.###.#.###.#.###.#.# +#...............#.###...#...#.#.....#...#.#.#...#.#.#...#.#...#.#.#...#...#...#.....#...#...#.#...#.......#.#...#...#...#...#...#...#.#...#.# +###############.#.###.#.#####.#####.#.###.#.#####.#.###.#.#.###.#.#.#####.#########.###.###.#.#.###.#######.#####.#.#.#.###.#####.###.#.###.# +###...###...#...#.....#...#...#.....#...#.#...#...#.#...#.#.###.#.#...#...#...#...#.#...###.#.#...#.###...#.#.....#...#.....#...#.#...#...#.# +###.#.###.#.#.###########.#.###.#######.#.###.#.###.#.###.#.###.#.###.#.###.#.#.#.#.#.#####.#.###.#.###.#.#.#.###############.#.#.#.#####.#.# +#...#.#...#...#...#.....#.#...#...#...#.#...#.#...#.#.#...#.#...#...#.#...#.#.#.#.#.#...#...#...#.#.#...#...#.###...#...#...#.#.#.#.......#.# +#.###.#.#######.#.#.###.#.###.###.#.#.#.###.#.###.#.#.#.###.#.#####.#.###.#.#.#.#.#.###.#.#####.#.#.#.#######.###.#.#.#.#.#.#.#.#.#########.# +#...#.#.........#...#...#...#...#...#.#.#...#...#.#.#.#.#...#.#...#.#.###...#.#.#...#...#.#...#...#...###...#.#...#...#...#.#.#.#.#.......#.# +###.#.###############.#####.###.#####.#.#.#####.#.#.#.#.#.###.#.#.#.#.#######.#.#####.###.#.#.###########.#.#.#.###########.#.#.#.#.#####.#.# +#...#...........#.....#...#.....#...#...#.#...#.#.#.#.#.#...#...#.#...#.......#.....#...#...#.#...........#...#.#...........#.#...#.....#.#.# +#.#############.#.#####.#.#######.#.#####.#.#.#.#.#.#.#.###.#####.#####.###########.###.#####.#.###############.#.###########.#########.#.#.# +#.............#.#.....#.#.........#.....#.#.#.#.#.#.#.#...#...#...#.....#.....#.....###...#...#.#.........#...#.#.......#.....#.........#...# +#############.#.#####.#.###############.#.#.#.#.#.#.#.###.###.#.###.#####.###.#.#########.#.###.#.#######.#.#.#.#######.#.#####.############# +###...#...#...#...###...#...............#.#.#.#.#.#.#.#...#...#...#.#...#...#.#.....#.....#...#.#.#.....#...#...#.......#.#...#.........#...# +###.#.#.#.#.#####.#######.###############.#.#.#.#.#.#.#.###.#####.#.#.#.###.#.#####.#.#######.#.#.#.###.#########.#######.#.#.#########.#.#.# +#...#...#...#.....#.......#.....#.......#...#...#...#.#.###.....#.#.#.#.#...#.#.....#.#.....#.#...#...#.........#...###...#.#.#...#...#...#.# +#.###########.#####.#######.###.#.#####.#############.#.#######.#.#.#.#.#.###.#.#####.#.###.#.#######.#########.###.###.###.#.#.#.#.#.#####.# +#.........#...#...#.........###...#...#.........#.....#...#...#.#.#...#...###.#.#.....#...#.#.....#...#.......#...#.....#...#...#...#.......# +#########.#.###.#.#################.#.#########.#.#######.#.#.#.#.###########.#.#.#######.#.#####.#.###.#####.###.#######.################### +#...#.....#.....#.....#...#...#.....#.........#.#.....#...#.#...#...........#...#.......#.#.......#...#.#.....###.........###...#.....#.....# +#.#.#.###############.#.#.#.#.#.#############.#.#####.#.###.###############.###########.#.###########.#.#.###################.#.#.###.#.###.# +#.#.#...#.....#.....#.#.#.#.#...#...#...#...#...#...#...###.......#.....#...#...........#.#.........#...#...........#...#...#.#.#.#...#.#...# +#.#.###.#.###.#.###.#.#.#.#.#####.#.#.#.#.#.#####.#.#############.#.###.#.###.###########.#.#######.###############.#.#.#.#.#.#.#.#.###.#.### +#.#.....#.#...#...#.#...#...#...#.#...#...#.......#...#...........#.###...###.......#.....#.......#...........#...#...#...#...#...#.....#...# +#.#######.#.#####.#.#########.#.#.###################.#.###########.###############.#.###########.###########.#.#.#########################.# +#.#...#...#.......#.....#.....#...#...#...#.......#...#...#.......#.............#...#.#...........#...#...###...#.#...#...#...#...#...#...#.# +#.#.#.#.###############.#.#########.#.#.#.#.#####.#.#####.#.#####.#############.#.###.#.###########.#.#.#.#######.#.#.#.#.#.#.#.#.#.#.#.#.#.# +#...#.#.###...#...#.....#...#.......#...#.#.#...#...#...#...#.....#...#...#.....#.#...#.#...#.......#.#.#.......#.#.#...#.#.#...#.#.#.#.#.#.# +#####.#.###.#.#.#.#.#######.#.###########.#.#.#.#####.#.#####.#####.#.#.#.#.#####.#.###.#.#.#.#######.#.#######.#.#.#####.#.#####.#.#.#.#.#.# +###...#...#.#...#...#.......#...........#.#...#.......#.#.....#...#.#.#.#.#.#.....#.###...#...###...#...#...#...#.#...#...#...###...#.#.#...# +###.#####.#.#########.#################.#.#############.#.#####.#.#.#.#.#.#.#.#####.#############.#.#####.#.#.###.###.#.#####.#######.#.##### +#...#...#.#.....#...#.###...###...#...#.#.#...#.........#.#...#.#...#.#.#.#.#.#...#.#.........#...#.......#...###.....#.....#.......#.#.....# +#.###.#.#.#####.#.#.#.###.#.###.#.#.#.#.#.#.#.#.#########.#.#.#.#####.#.#.#.#.#.#.#.#.#######.#.###########################.#######.#.#####.# +#.#...#.#.#...#...#...#...#.....#...#...#...#.#.........#.#.#...#...#.#.#...#...#.#.#.....#...#...........#...............#.#...#...#.#...#.# +#.#.###.#.#.#.#########.#####################.#########.#.#.#####.#.#.#.#########.#.#####.#.#############.#.#############.#.#.#.#.###.#.#.#.# +#.#...#...#.#.#.........#...................#...........#.#...#...#.#...#...#...#.#.#.....#.###...........#.#.............#...#...###...#...# +#.###.#####.#.#.#########.#################.#############.###.#.###.#####.#.#.#.#.#.#.#####.###.###########.#.############################### +#.#...#.....#.#...........#...#.............###.........#.....#...#.#...#.#.#.#.#...#.....#...#.............#.#.........#...................# +#.#.###.#####.#############.#.#.###############.#######.#########.#.#.#.#.#.#.#.#########.###.###############.#.#######.#.#################.# +#...#...#...#.........###...#...#...#...#.......#...#...#.........#...#...#...#.....#...#.#...#...#...#.....#...#.....#...#.................# +#####.###.#.#########.###.#######.#.#.#.#.#######.#.#.###.#########################.#.#.#.#.###.#.#.#.#.###.#####.###.#####.################# +#...#.....#.........#.....#.......#...#...#...#...#...#...#.........#.............#...#...#.....#...#.#...#.....#...#.#.....#.....#.........# +#.#.###############.#######.###############.#.#.#######.###.#######.#.###########.###################.###.#####.###.#.#.#####.###.#.#######.# +#.#.#...###...#...#.......#.#.....#...#.....#...#.....#.....#######...###.........#...#.....#...#...#...#.....#.....#...#...#...#.#.#.......# +#.#.#.#.###.#.#.#.#######.#.#.###.#.#.#.#########.###.###################.#########.#.#.###.#.#.#.#.###.#####.###########.#.###.#.#.#.####### +#.#.#.#.#...#...#.........#.#...#...#...#.........#...###################...#.....#.#.#.###...#.#.#...#.#...#...#...#.....#.....#.#.#.......# +#.#.#.#.#.#################.###.#########.#########.#######################.#.###.#.#.#.#######.#.###.#.#.#.###.#.#.#.###########.#.#######.# +#.#...#...#...#.........#...###...........#.........#######################...###...#.#.....###.#.#...#...#...#.#.#...#...#.....#.#.#.....#.# +#.#########.#.#.#######.#.#################.#########################################.#####.###.#.#.#########.#.#.#####.#.#.###.#.#.#.###.#.# +#.#...#.....#.#.#.......#...#.........#...#.......#################S..#...#.........#...#...#...#.#.#.....###...#.#.....#.#.#...#...#...#...# +#.#.#.#.#####.#.#.#########.#.#######.#.#.#######.###################.#.#.#.#######.###.#.###.###.#.#.###.#######.#.#####.#.#.#########.##### +#.#.#.#.#.....#.#...........#.......#...#.#.....#...#################.#.#.#.....#...###...###.#...#.#...#...#...#.#.....#...#.........#.....# +#.#.#.#.#.#####.###################.#####.#.###.###.#################.#.#.#####.#.###########.#.###.###.###.#.#.#.#####.#############.#####.# +#.#.#...#...#...###.......#...###...#...#...###...#.###############...#.#.###...#.#.........#...###.....#...#.#...#...#...###.......#.#...#.# +#.#.#######.#.#####.#####.#.#.###.###.#.#########.#.###############.###.#.###.###.#.#######.#############.###.#####.#.###.###.#####.#.#.#.#.# +#.#.#.......#.#...#.....#...#...#...#.#.###...###.#.#########.......#...#...#...#.#.#.......###...........#...#.....#...#.....#.....#...#...# +#.#.#.#######.#.#.#####.#######.###.#.#.###.#.###.#.#########.#######.#####.###.#.#.#.#########.###########.###.#######.#######.############# +#...#.........#.#.....#.......#...#...#.....#...#...#######...#...###.....#.#...#.#.#.#.......#...........#...#.#...###.........#...........# +###############.#####.#######.###.#############.###########.###.#.#######.#.#.###.#.#.#.#####.###########.###.#.#.#.#############.#########.# +###...#...#...#.....#.#...###...#.#...#.........#E#########...#.#...#...#.#.#...#.#.#.#.#.....###...#...#.....#...#...............#...#.....# +###.#.#.#.#.#.#####.#.#.#.#####.#.#.#.#.#########.###########.#.###.#.#.#.#.###.#.#.#.#.#.#######.#.#.#.###########################.#.#.##### +#...#...#...#.......#...#.....#.#...#...###...###.#########...#.#...#.#...#.#...#...#...#.....#...#...#.#.........#...#.....#...#...#...#...# +#.###########################.#.###########.#.###.#########.###.#.###.#####.#.###############.#.#######.#.#######.#.#.#.###.#.#.#.#######.#.# +#...................#...#...#.#.....#.......#...#.#########...#.#...#.....#.#.......#...#.....#.......#.#.......#.#.#.#...#...#.#.#.......#.# +###################.#.#.#.#.#.#####.#.#########.#.###########.#.###.#####.#.#######.#.#.#.###########.#.#######.#.#.#.###.#####.#.#.#######.# +#.......#...#.......#.#...#.#.......#.#...#.....#...#.........#.#...###...#...#...#.#.#...#...#.......#.........#...#...#.#...#...#...#...#.# +#.#####.#.#.#.#######.#####.#########.#.#.#.#######.#.#########.#.#####.#####.#.#.#.#.#####.#.#.#######################.#.#.#.#######.#.#.#.# +#.#...#...#...#...#...#.....#.........#.#...#...#...#.###...###.#.#...#.#.....#.#...#...#...#.#...............#...###...#...#.........#.#.#.# +#.#.#.#########.#.#.###.#####.#########.#####.#.#.###.###.#.###.#.#.#.#.#.#####.#######.#.###.###############.#.#.###.#################.#.#.# +#...#...#.....#.#...#...#...#.#.......#.....#.#.#...#.#...#...#.#.#.#.#.#.#...#.....#...#.#...#...#.........#...#...#.....#.............#...# +#######.#.###.#.#####.###.#.#.#.#####.#####.#.#.###.#.#.#####.#.#.#.#.#.#.#.#.#####.#.###.#.###.#.#.#######.#######.#####.#.################# +#.....#.#.###...#...#.....#.#.#.....#.......#.#.#...#...#.....#.#.#.#.#.#.#.#.#.....#...#.#...#.#.#.......#.........#...#...###...#.........# +#.###.#.#.#######.#.#######.#.#####.#########.#.#.#######.#####.#.#.#.#.#.#.#.#.#######.#.###.#.#.#######.###########.#.#######.#.#.#######.# +#...#...#.#.......#.......#...#.....#...#...#.#.#.......#.#...#.#.#.#.#.#.#.#.#.......#.#.#...#.#.#...###...#.........#.........#...#.......# +###.#####.#.#############.#####.#####.#.#.#.#.#.#######.#.#.#.#.#.#.#.#.#.#.#.#######.#.#.#.###.#.#.#.#####.#.#######################.####### +#...#...#.#.........#...#...#...#...#.#.#.#.#.#.#...#...#.#.#.#.#.#.#.#.#.#.#...#...#.#.#.#...#.#.#.#.....#...#...#...#.....#.........###...# +#.###.#.#.#########.#.#.###.#.###.#.#.#.#.#.#.#.#.#.#.###.#.#.#.#.#.#.#.#.#.###.#.#.#.#.#.###.#.#.#.#####.#####.#.#.#.#.###.#.###########.#.# +#...#.#.#.###...###...#...#...#...#...#.#.#...#.#.#.#.###.#.#.#.#.#.#.#.#...###.#.#...#...###.#.#...###...#...#.#.#.#.#.###...#...#.......#.# +###.#.#.#.###.#.#########.#####.#######.#.#####.#.#.#.###.#.#.#.#.#.#.#.#######.#.###########.#.#######.###.#.#.#.#.#.#.#######.#.#.#######.# +#...#.#.#.#...#.#.........#...#.#.......#...###.#.#.#.#...#.#.#.#...#...###.....#...........#.#.#.......#...#...#...#...#...###.#.#.#...#...# +#.###.#.#.#.###.#.#########.#.#.#.#########.###.#.#.#.#.###.#.#.###########.###############.#.#.#.#######.###############.#.###.#.#.#.#.#.### +#.#...#...#...#...#...#...#.#.#.#...#.....#...#...#.#.#...#.#.#.#.....#.....#...#...#...#...#.#.#.#...#...###...#...#...#.#.....#...#.#...### +#.#.#########.#####.#.#.#.#.#.#.###.#.###.###.#####.#.###.#.#.#.#.###.#.#####.#.#.#.#.#.#.###.#.#.#.#.#.#####.#.#.#.#.#.#.###########.####### +#.#.#.........#...#.#...#...#.#.#...#...#...#.....#...###...#.#...#...#.#.....#.#.#.#.#.#...#.#.#...#.#.......#...#.#.#.#.#.....#...#.#.....# +#.#.#.#########.#.#.#########.#.#.#####.###.#####.###########.#####.###.#.#####.#.#.#.#.###.#.#.#####.#############.#.#.#.#.###.#.#.#.#.###.# +#.#.#.........#.#.#.#.......#...#.....#.#...#...#...#.......#.#...#...#.#.#.....#.#.#.#.#...#...#...#.....#.......#...#...#...#.#.#.#...#...# +#.#.#########.#.#.#.#.#####.#########.#.#.###.#.###.#.#####.#.#.#.###.#.#.#.#####.#.#.#.#.#######.#.#####.#.#####.###########.#.#.#.#####.### +#...#...###...#.#.#.#.#...#...........#.#.#...#.#...#.....#...#.#.#...#...#.....#.#.#.#.#.....#...#.#.....#...#...#...#...#...#.#.#.#.....### +#####.#.###.###.#.#.#.#.#.#############.#.#.###.#.#######.#####.#.#.###########.#.#.#.#.#####.#.###.#.#######.#.###.#.#.#.#.###.#.#.#.####### +#.....#.....#...#...#...#.........#...#.#.#.###...###.....#...#.#...#...#.......#.#...#.#...#...#...#.#...#...#...#.#.#.#.#.###.#.#.#.......# +#.###########.###################.#.#.#.#.#.#########.#####.#.#.#####.#.#.#######.#####.#.#.#####.###.#.#.#.#####.#.#.#.#.#.###.#.#.#######.# +#.....#.....#.....###...###...#...#.#...#.#.#.........#...#.#.#...#...#.#.#.....#.....#...#.....#...#.#.#.#.#.....#.#.#.#.#...#...#...#...#.# +#####.#.###.#####.###.#.###.#.#.###.#####.#.#.#########.#.#.#.###.#.###.#.#.###.#####.#########.###.#.#.#.#.#.#####.#.#.#.###.#######.#.#.#.# +#...#...#...#...#.#...#.....#...#...#...#...#.........#.#.#.#...#...#...#.#.#...#...#.......###.....#...#.#.#.....#.#.#.#...#...#...#...#...# +#.#.#####.###.#.#.#.#############.###.#.#############.#.#.#.###.#####.###.#.#.###.#.#######.#############.#.#####.#.#.#.###.###.#.#.######### +#.#.....#...#.#...#.#...#...#...#.....#.#.........###.#.#.#...#...#...###...#...#.#...#...#.............#...#...#.#.#...###...#...#...#...### +#.#####.###.#.#####.#.#.#.#.#.#.#######.#.#######.###.#.#.###.###.#.###########.#.###.#.#.#############.#####.#.#.#.#########.#######.#.#.### +#.#...#.....#.....#...#.#.#.#.#...#...#.#.#.....#.....#.#.#...###.#.....#.......#...#.#.#.#...#...#...#...#...#...#.###...###.#.....#...#...# +#.#.#.###########.#####.#.#.#.###.#.#.#.#.#.###.#######.#.#.#####.#####.#.#########.#.#.#.#.#.#.#.#.#.###.#.#######.###.#.###.#.###.#######.# +#.#.#...#...#...#...###...#.#.###...#...#...#...#.......#.#.....#.#.....#.....#...#.#...#...#.#.#.#.#...#.#...#...#.....#...#.#.#...#.....#.# +#.#.###.#.#.#.#.###.#######.#.###############.###.#######.#####.#.#.#########.#.#.#.#########.#.#.#.###.#.###.#.#.#########.#.#.#.###.###.#.# +#.#.#...#.#.#.#...#.....#...#.#...............#...#.......#.....#.#...#.......#.#.#.........#.#.#.#.#...#...#.#.#.#.....#...#.#.#.#...#...#.# +#.#.#.###.#.#.###.#####.#.###.#.###############.###.#######.#####.###.#.#######.#.#########.#.#.#.#.#.#####.#.#.#.#.###.#.###.#.#.#.###.###.# +#.#.#...#.#.#...#...#...#.....#...#...#.....#...###...#...#.....#...#.#...#...#.#...#.....#.#.#.#.#.#.#.....#...#.#.###...###.#.#...#...#...# +#.#.###.#.#.###.###.#.###########.#.#.#.###.#.#######.#.#.#####.###.#.###.#.#.#.###.#.###.#.#.#.#.#.#.#.#########.#.#########.#.#####.###.### +#...###.#.#.#...###...###.........#.#.#...#.#...#...#.#.#.#.....###.#...#.#.#.#.#...#...#...#.#.#...#.#.#.........#...###...#...#...#...#...# +#######.#.#.#.###########.#########.#.###.#.###.#.#.#.#.#.#.#######.###.#.#.#.#.#.#####.#####.#.#####.#.#.###########.###.#.#####.#.###.###.# +#.......#.#.#.#...........#.....#...#.#...#...#...#.#.#.#.#...#.....#...#.#.#.#.#.#...#...#...#.....#.#.#...#...#...#.....#.......#...#.#...# +#.#######.#.#.#.###########.###.#.###.#.#####.#####.#.#.#.###.#.#####.###.#.#.#.#.#.#.###.#.#######.#.#.###.#.#.#.#.#################.#.#.### +#.........#...#.............###...###...#####.......#...#.....#.......###...#...#...#.....#.........#...###...#...#...................#...### +############################################################################################################################################# diff --git a/day20/sample.txt b/day20/sample.txt new file mode 100644 index 0000000..c097dae --- /dev/null +++ b/day20/sample.txt @@ -0,0 +1,15 @@ +############### +#...#...#.....# +#.#.#.#.#.###.# +#S#...#.#.#...# +#######.#.#.### +#######.#.#...# +#######.#.###.# +###..E#...#...# +###.#######.### +#...###...#...# +#.#####.#.###.# +#.#...#.#.#...# +#.#.#.#.#.#.### +#...#...#...### +###############