Compare commits

...

5 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
dobiadi
23d9bd4106 Day22 C 2023-12-23 21:12:34 +01:00
dobiadi
6646cf557f Day19 C 2023-12-23 00:18:03 +01:00
dobiadi
4427590639 Day18 C 2023-12-22 13:34:50 +01:00
25 changed files with 4617 additions and 0 deletions

BIN
day18/c/day18 Executable file
View File

Binary file not shown.

369
day18/c/day18.c Normal file
View File

@@ -0,0 +1,369 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <limits.h>
#define LINE_MAX_LENGTH 256
#define MAX_ENTRIES 2048
#define MAX_QUEUE_LEN 256
#define MAX_EDGES 1024
#define MAX_BREAKPOINTS 512
#define min(a,b) ((a) < (b) ? (a) : (b))
#define max(a,b) ((a) > (b) ? (a) : (b))
typedef struct entry {
char direction;
long long count;
char rgb_string[10];
} entry_t;
typedef struct zone {
long long upper_left_corner[2];
long long lower_right_corner[2];
uint8_t outside;
} zone_t;
int cmp(const void* a, const void* b);
int on_edge(long long edges[MAX_EDGES][2][2], int edges_num, long long side[2][2]);
unsigned long long lake_volume(entry_t entries[], int entries_num);
void decode_rgbs(entry_t entries[], int entries_num);
int main() {
char *p, *buf, c;
buf = (char *)malloc(LINE_MAX_LENGTH);
memset(buf, 0, LINE_MAX_LENGTH);
p = buf;
entry_t entries[MAX_ENTRIES];
memset(entries, 0, MAX_ENTRIES * sizeof(entry_t));
int entries_num = 0;
while ((c = getchar()) != EOF) {
*p++ = c;
if (c == '\n') {
sscanf(buf, "%c %lli %s", &entries[entries_num].direction, &entries[entries_num].count, entries[entries_num].rgb_string);
entries_num++;
memset(buf, 0, LINE_MAX_LENGTH);
p = buf;
}
}
unsigned long long part1 = lake_volume(entries, entries_num);
decode_rgbs(entries, entries_num);
unsigned long long part2 = lake_volume(entries, entries_num);
printf("%llu\n", part1);
printf("%llu\n", part2);
free(buf);
}
int cmp(const void* a, const void* b) {
return *(long long*)a - *(long long*)b;
}
int on_edge(long long edges[MAX_EDGES][2][2], int edges_num, long long side[2][2]) {
for (int i = 0; i < edges_num; i++) {
if (edges[i][0][0] == side[0][0] && edges[i][0][0] == edges[i][1][0] && side[0][0] == side[1][0] && edges[i][0][1] <= side[0][1] && edges[i][1][1] >= side[1][1]) {
return 1;
}
if (edges[i][0][1] == side[0][1] && edges[i][0][1] == edges[i][1][1] && side[0][1] == side[1][1] && edges[i][0][0] <= side[0][0] && edges[i][1][0] >= side[1][0]) {
return 1;
}
}
return 0;
}
unsigned long long lake_volume(entry_t entries[], int entries_num) {
long long x = 0, y = 0, dir[2];
long long edges[MAX_EDGES][2][2];
memset(edges, 0, MAX_EDGES * 2 * 2 * sizeof(long long));
int edges_num = 0;
for (int i = 0; i < entries_num; i++) {
switch (entries[i].direction) {
case 'R':
dir[0] = 1;
dir[1] = 0;
edges[edges_num][0][0] = x;
edges[edges_num][0][1] = y;
edges[edges_num][1][0] = x + entries[i].count * dir[0];
edges[edges_num][1][1] = y + entries[i].count * dir[1];
edges_num++;
break;
case 'L':
dir[0] = -1;
dir[1] = 0;
edges[edges_num][1][0] = x;
edges[edges_num][1][1] = y;
edges[edges_num][0][0] = x + entries[i].count * dir[0];
edges[edges_num][0][1] = y + entries[i].count * dir[1];
edges_num++;
break;
case 'U':
dir[0] = 0;
dir[1] = -1;
edges[edges_num][1][0] = x;
edges[edges_num][1][1] = y;
edges[edges_num][0][0] = x + entries[i].count * dir[0];
edges[edges_num][0][1] = y + entries[i].count * dir[1];
edges_num++;
break;
case 'D':
dir[0] = 0;
dir[1] = 1;
edges[edges_num][0][0] = x;
edges[edges_num][0][1] = y;
edges[edges_num][1][0] = x + entries[i].count * dir[0];
edges[edges_num][1][1] = y + entries[i].count * dir[1];
edges_num++;
break;
}
x += entries[i].count * dir[0];
y += entries[i].count * dir[1];
}
// Find smallest and largest x and y
long long min_x = LLONG_MAX, max_x = LLONG_MIN, min_y = LLONG_MAX, max_y = LLONG_MIN;
for (int i = 0; i < edges_num; i++) {
if (edges[i][0][0] < min_x) {
min_x = edges[i][0][0];
}
if (edges[i][1][0] > max_x) {
max_x = edges[i][1][0];
}
if (edges[i][0][1] < min_y) {
min_y = edges[i][0][1];
}
if (edges[i][1][1] > max_y) {
max_y = edges[i][1][1];
}
}
// X breakpoints
long long x_breakpoints[MAX_BREAKPOINTS], x_breakpoints_num = 0;
for (int i = 0; i < edges_num; i++) {
int found = 0;
for (int j = 0; j < x_breakpoints_num; j++) {
if (edges[i][0][0] == x_breakpoints[j]) {
found = 1;
break;
}
}
if (!found) {
x_breakpoints[x_breakpoints_num] = edges[i][0][0];
x_breakpoints_num++;
}
found = 0;
for (int j = 0; j < x_breakpoints_num; j++) {
if (edges[i][1][0] == x_breakpoints[j]) {
found = 1;
break;
}
}
if (!found) {
x_breakpoints[x_breakpoints_num] = edges[i][1][0];
x_breakpoints_num++;
}
}
qsort(x_breakpoints, x_breakpoints_num, sizeof(x_breakpoints[0]), &cmp);
// Y breakpoints
long long y_breakpoints[MAX_BREAKPOINTS], y_breakpoints_num = 0;
for (int i = 0; i < edges_num; i++) {
int found = 0;
for (int j = 0; j < y_breakpoints_num; j++) {
if (edges[i][0][1] == y_breakpoints[j]) {
found = 1;
break;
}
}
if (!found) {
y_breakpoints[y_breakpoints_num] = edges[i][0][1];
y_breakpoints_num++;
}
found = 0;
for (int j = 0; j < y_breakpoints_num; j++) {
if (edges[i][1][1] == y_breakpoints[j]) {
found = 1;
break;
}
}
if (!found) {
y_breakpoints[y_breakpoints_num] = edges[i][1][1];
y_breakpoints_num++;
}
}
qsort(y_breakpoints, y_breakpoints_num, sizeof(y_breakpoints[0]), &cmp);
zone_t **zones = (zone_t**)malloc((x_breakpoints_num - 1) * sizeof(zone_t*));
for (int i = 0; i < x_breakpoints_num - 1; i++) {
zones[i] = (zone_t*)malloc((y_breakpoints_num - 1) * sizeof(zone_t));
memset(zones[i], 0, (y_breakpoints_num - 1) * sizeof(zone_t));
}
zone_t *curr;
for (int i = 0; i < y_breakpoints_num - 1; i++) {
for (int j = 0; j < x_breakpoints_num - 1; j++) {
curr = &zones[j][i];
curr->upper_left_corner[0] = x_breakpoints[j];
curr->upper_left_corner[1] = y_breakpoints[i];
curr->lower_right_corner[0] = x_breakpoints[j + 1];
curr->lower_right_corner[1] = y_breakpoints[i + 1];
}
}
// Mark zones as outside
int found = 1;
while (found) {
found = 0;
for (int i = 0; i < y_breakpoints_num - 1; i++) {
for (int j = 0; j < x_breakpoints_num - 1; j++) {
if (zones[j][i].outside) {
continue;
}
// LEFT
long long side[2][2];
side[0][0] = zones[j][i].upper_left_corner[0];
side[0][1] = zones[j][i].upper_left_corner[1];
side[1][0] = zones[j][i].upper_left_corner[0];
side[1][1] = zones[j][i].lower_right_corner[1];
if (j == 0 && !on_edge(edges, edges_num, side)) {
zones[j][i].outside = 1;
found = 1;
}
if (j > 0 && zones[j-1][i].outside && !on_edge(edges, edges_num, side)) {
zones[j][i].outside = 1;
found = 1;
}
// RIGHT
side[0][0] = zones[j][i].lower_right_corner[0];
side[0][1] = zones[j][i].upper_left_corner[1];
side[1][0] = zones[j][i].lower_right_corner[0];
side[1][1] = zones[j][i].lower_right_corner[1];
if (j == x_breakpoints_num - 2 && !on_edge(edges, edges_num, side)) {
zones[j][i].outside = 1;
found = 1;
}
if (j < x_breakpoints_num - 2 && zones[j+1][i].outside && !on_edge(edges, edges_num, side)) {
zones[j][i].outside = 1;
found = 1;
}
// UP
side[0][0] = zones[j][i].upper_left_corner[0];
side[0][1] = zones[j][i].upper_left_corner[1];
side[1][0] = zones[j][i].lower_right_corner[0];
side[1][1] = zones[j][i].upper_left_corner[1];
if (i == 0 && !on_edge(edges, edges_num, side)) {
zones[j][i].outside = 1;
found = 1;
}
if (i > 0 && zones[j][i-1].outside && !on_edge(edges, edges_num, side)) {
zones[j][i].outside = 1;
found = 1;
}
// DOWN
side[0][0] = zones[j][i].upper_left_corner[0];
side[0][1] = zones[j][i].lower_right_corner[1];
side[1][0] = zones[j][i].lower_right_corner[0];
side[1][1] = zones[j][i].lower_right_corner[1];
if (i == y_breakpoints_num - 2 && !on_edge(edges, edges_num, side)) {
zones[j][i].outside = 1;
found = 1;
}
if (i < y_breakpoints_num - 2 && zones[j][i+1].outside && !on_edge(edges, edges_num, side)) {
zones[j][i].outside = 1;
found = 1;
}
}
}
}
unsigned long long sum = 0;
unsigned long long out = 0;
for (int i = 0; i < y_breakpoints_num - 1; i++) {
for (int j = 0; j < x_breakpoints_num - 1; j++) {
if (zones[j][i].outside) {
out++;
}
}
}
for (int i = 0; i < y_breakpoints_num - 1; i++) {
for (int j = 0; j < x_breakpoints_num - 1; j++) {
if (zones[j][i].outside) {
continue;
}
sum += (zones[j][i].lower_right_corner[0] - zones[j][i].upper_left_corner[0] - 1) * (zones[j][i].lower_right_corner[1] - zones[j][i].upper_left_corner[1] - 1);
// RIGHT
long long side[2][2];
side[0][0] = zones[j][i].lower_right_corner[0];
side[0][1] = zones[j][i].upper_left_corner[1];
side[1][0] = zones[j][i].lower_right_corner[0];
side[1][1] = zones[j][i].lower_right_corner[1];
if (!on_edge(edges, edges_num, side)) {
sum += side[1][1] - side[0][1] - 1;
}
// DOWN
side[0][1] = zones[j][i].lower_right_corner[1];
side[0][0] = zones[j][i].upper_left_corner[0];
side[1][0] = zones[j][i].lower_right_corner[0];
side[1][1] = zones[j][i].lower_right_corner[1];
if (!on_edge(edges, edges_num, side)) {
sum += side[1][0] - side[0][0] - 1;
}
// CORNER
side[0][1] = zones[j][i].lower_right_corner[1];
side[0][0] = zones[j][i].lower_right_corner[0];
side[1][0] = zones[j][i].lower_right_corner[0];
side[1][1] = zones[j][i].lower_right_corner[1];
if (!on_edge(edges, edges_num, side)) {
sum++;
}
}
}
for (int i = 0; i < edges_num; i++) {
sum += (edges[i][1][0] - edges[i][0][0]) + (edges[i][1][1] - edges[i][0][1]);
}
for (int i = 0; i < x_breakpoints_num - 1; i++) {
free(zones[i]);
}
free(zones);
return sum;
}
void decode_rgbs(entry_t entries[], int entries_num) {
for (int i = 0; i < entries_num; i++) {
char value[6], *p;
memset(value, 0, 6);
p = entries[i].rgb_string;
while(*p != '#') p++;
p++;
strncpy(value, p, 5);
sscanf(value, "%llx", &entries[i].count);
switch(entries[i].rgb_string[7]) {
case '0':
entries[i].direction = 'R';
break;
case '1':
entries[i].direction = 'D';
break;
case '2':
entries[i].direction = 'L';
break;
case '3':
entries[i].direction = 'U';
break;
}
}
}

660
day18/input.txt Normal file
View File

@@ -0,0 +1,660 @@
L 3 (#07b412)
D 5 (#713ad1)
L 2 (#11e6d2)
D 4 (#6ba7d3)
L 3 (#7cfca2)
U 5 (#0a85c3)
L 2 (#3a5282)
U 4 (#6f91a3)
L 3 (#32c2f0)
U 6 (#2dd7b3)
L 6 (#848c30)
U 7 (#077a43)
R 5 (#ba4692)
U 6 (#49b551)
R 3 (#14d162)
U 8 (#397871)
R 5 (#1c73f2)
D 8 (#7130e1)
R 4 (#c84852)
U 2 (#203b91)
R 3 (#288e30)
U 5 (#91ba91)
R 4 (#5dda70)
U 3 (#91ba93)
R 4 (#732500)
U 4 (#0676f1)
L 9 (#6701a2)
U 4 (#5c38c1)
L 7 (#0f7480)
U 4 (#921b21)
L 6 (#83d9e0)
U 2 (#28c691)
L 7 (#1b6de0)
U 2 (#02cee1)
L 4 (#5b66b0)
U 4 (#bdb093)
L 6 (#75eb20)
U 4 (#928251)
L 4 (#6bb430)
D 7 (#44ad91)
L 2 (#806b50)
U 7 (#7d1391)
L 4 (#7a3652)
U 5 (#9cbf41)
L 5 (#905712)
U 2 (#70beb3)
L 2 (#bede02)
U 7 (#70beb1)
R 3 (#a2c232)
U 5 (#7b0ad1)
R 5 (#01d012)
U 5 (#2b1901)
R 7 (#698c32)
U 4 (#a19d91)
R 4 (#7dbb92)
U 3 (#8feb41)
R 5 (#021ab2)
U 3 (#42a773)
R 6 (#99c6c2)
D 7 (#8f7b33)
R 5 (#01fd82)
D 5 (#8e7263)
R 2 (#37e492)
U 5 (#10bff3)
R 5 (#a09242)
U 7 (#126723)
R 3 (#864230)
D 8 (#70bc43)
R 5 (#7cf4a0)
D 2 (#8135d3)
R 6 (#144b70)
U 5 (#0c51e3)
L 6 (#00e590)
U 4 (#44ba73)
L 2 (#4177e2)
U 4 (#a4c5b1)
L 6 (#6f2f12)
U 3 (#9a4ce1)
L 4 (#979402)
D 7 (#2a0ce1)
L 3 (#0c1b70)
U 7 (#58ca71)
L 3 (#95d640)
U 4 (#549241)
R 10 (#a1f1b2)
U 3 (#1753b1)
L 5 (#1d32d2)
U 5 (#9a58d3)
L 5 (#4dc1b2)
U 6 (#1ab693)
L 4 (#5e8df2)
U 3 (#4dabf3)
R 6 (#972492)
U 5 (#3198c3)
R 4 (#972490)
U 3 (#54b613)
R 6 (#4a8bb2)
U 2 (#a4c5b3)
R 3 (#126042)
U 9 (#54acc3)
L 5 (#2b4682)
U 4 (#88f453)
L 4 (#2b4680)
U 8 (#4a4283)
L 2 (#8bfdf0)
U 2 (#a76851)
L 4 (#0a9b30)
U 6 (#43a141)
L 3 (#14fd80)
U 3 (#7e5391)
L 6 (#43ba40)
D 2 (#146e93)
L 4 (#9c71b0)
D 7 (#5ae483)
L 5 (#0bcd70)
U 6 (#52a1c3)
L 4 (#3307f0)
U 4 (#1da3f3)
L 3 (#7a8c80)
D 5 (#89c463)
L 2 (#2984e0)
D 2 (#828673)
L 6 (#2cf252)
U 7 (#500061)
L 4 (#a07ff2)
U 3 (#565f21)
R 3 (#09ef22)
U 3 (#a65f83)
R 5 (#410672)
U 4 (#24fe73)
L 5 (#b6ed72)
U 8 (#4574d3)
L 6 (#2e3142)
D 8 (#7ba311)
L 3 (#1bc442)
U 6 (#38b161)
L 4 (#8ada92)
U 2 (#24cdf1)
L 3 (#37b3e2)
U 3 (#3a3ec1)
R 5 (#242ea2)
U 2 (#1fe073)
R 5 (#9ad182)
U 6 (#4a9193)
R 6 (#34c480)
U 2 (#9ff123)
R 5 (#34c482)
U 4 (#08fe03)
R 3 (#46d292)
D 10 (#19fca3)
R 3 (#1ea7d2)
D 6 (#c2d531)
R 8 (#614f82)
D 6 (#c2d533)
R 6 (#777202)
D 2 (#38f573)
R 3 (#84e142)
D 3 (#036d11)
R 5 (#113352)
D 5 (#036d13)
R 3 (#7ad752)
U 4 (#969de3)
R 7 (#7887d0)
U 3 (#31aa61)
R 4 (#affca0)
U 6 (#31aa63)
R 2 (#374010)
U 6 (#574d53)
L 4 (#4edbd2)
U 2 (#2271c1)
L 7 (#595d32)
U 3 (#2271c3)
R 3 (#2c6532)
U 5 (#2754d3)
R 8 (#8b2652)
U 4 (#b27ab3)
R 6 (#824b80)
D 4 (#587173)
R 4 (#3715b0)
D 5 (#8f0b61)
R 3 (#6a2ac0)
D 3 (#1e0b21)
R 5 (#29a290)
D 3 (#8850b3)
R 5 (#9013e0)
D 3 (#24c5d3)
R 5 (#2b12d0)
U 6 (#4090a3)
R 3 (#9cddd0)
D 6 (#a93843)
R 4 (#6fff30)
D 4 (#3f1121)
L 7 (#76f2c0)
D 4 (#4f9e11)
L 3 (#76f2c2)
D 8 (#480d31)
L 6 (#694740)
D 5 (#177e81)
L 9 (#692aa2)
D 3 (#10b971)
R 9 (#42f012)
D 3 (#10b973)
R 3 (#2c6202)
D 8 (#851881)
R 3 (#04ae62)
D 2 (#470d81)
R 4 (#155e10)
U 3 (#01b053)
R 2 (#c55dd0)
U 5 (#01b051)
R 9 (#026f30)
D 2 (#113081)
R 2 (#694742)
D 4 (#22d821)
L 5 (#03eb80)
D 5 (#3bc5d1)
L 4 (#69bf90)
D 3 (#3fdce3)
L 4 (#2d1350)
D 2 (#3fdce1)
L 3 (#65f500)
U 4 (#bd7f81)
L 8 (#8382e0)
D 4 (#160053)
L 7 (#5ff9f0)
D 4 (#ab40d3)
R 6 (#5ff9f2)
D 2 (#58d1b3)
R 2 (#6bcc80)
D 6 (#b187c3)
R 6 (#73b290)
D 3 (#9fbf43)
R 4 (#630f00)
D 2 (#4f1b13)
R 7 (#543b30)
D 7 (#114c43)
R 6 (#629ac0)
D 6 (#1bedb3)
R 4 (#016f50)
D 2 (#285e31)
R 3 (#611460)
D 7 (#0dfd61)
R 2 (#75f3e0)
D 2 (#1e79b1)
R 4 (#144e90)
U 5 (#d16ff1)
R 4 (#144e92)
U 6 (#113511)
R 5 (#610450)
U 3 (#1291c1)
R 2 (#328eb0)
U 5 (#2f3f73)
R 9 (#126af2)
U 4 (#946843)
L 6 (#126af0)
U 5 (#866453)
L 7 (#352e70)
U 4 (#5f8413)
L 7 (#c618e2)
U 3 (#6c2813)
L 2 (#c618e0)
U 3 (#1d3db3)
R 8 (#37e470)
U 2 (#1705b3)
R 6 (#6ab412)
U 6 (#961873)
R 3 (#6ab410)
U 8 (#30e6f3)
R 5 (#3308e0)
U 3 (#1fc8c1)
R 3 (#3450a0)
D 8 (#9d4391)
R 3 (#6a9c70)
D 2 (#25d071)
R 4 (#3e5330)
D 6 (#401381)
R 5 (#399052)
D 3 (#ab9e81)
R 4 (#2622a2)
D 4 (#68c4c3)
R 4 (#2c5f92)
D 3 (#8021d3)
R 5 (#75bd02)
D 3 (#1885a1)
R 3 (#67b420)
D 3 (#7df001)
R 6 (#67b422)
D 2 (#5270f1)
R 3 (#2bbed2)
D 9 (#863371)
L 3 (#45ba70)
D 6 (#49f553)
L 2 (#693800)
D 6 (#49f551)
L 7 (#450b90)
D 7 (#3b7aa1)
R 5 (#399050)
D 2 (#0b37f1)
R 4 (#5cbff0)
U 4 (#573103)
R 3 (#3668c0)
U 9 (#573101)
R 4 (#7d0a50)
U 7 (#316341)
R 3 (#4cbab0)
U 8 (#5c0f21)
R 3 (#22b3a2)
U 3 (#804941)
R 4 (#22b3a0)
U 7 (#173641)
R 5 (#1b7230)
U 3 (#8a0511)
R 4 (#1a5f82)
D 5 (#52eda1)
R 4 (#1a5f80)
U 5 (#38db21)
R 5 (#2f4720)
U 2 (#2a75c1)
R 9 (#aa4d40)
U 3 (#538141)
L 3 (#7ad770)
U 5 (#66ec01)
L 5 (#53e812)
U 3 (#539a81)
L 4 (#53e810)
U 5 (#413821)
L 5 (#618330)
D 5 (#a4bf71)
L 6 (#56e4b2)
U 3 (#acf591)
L 2 (#890732)
U 8 (#2a62d1)
R 4 (#458e22)
U 5 (#2ef8e3)
R 4 (#273c60)
U 4 (#439bc3)
R 2 (#273c62)
D 4 (#64c3c3)
R 5 (#0e0c12)
D 5 (#9481d1)
R 3 (#5321d2)
U 4 (#5d6361)
R 7 (#531760)
U 7 (#068711)
R 7 (#216570)
U 7 (#a20e51)
L 3 (#216572)
D 3 (#46afb1)
L 8 (#4e8f70)
D 6 (#1261b1)
L 5 (#3840e0)
U 6 (#7b0901)
L 3 (#75cf00)
U 3 (#b56e51)
L 7 (#43b850)
U 3 (#01dfc1)
L 6 (#067e40)
U 7 (#613913)
R 5 (#30ff10)
U 7 (#285d33)
R 5 (#72e5c0)
D 7 (#285d31)
R 3 (#3fdcf0)
U 6 (#601d03)
R 4 (#312812)
U 4 (#4ea643)
R 6 (#8253e2)
D 7 (#4ea641)
R 2 (#3045d2)
U 7 (#8362b3)
R 7 (#631a70)
U 4 (#ba56c3)
R 6 (#28e520)
U 2 (#568a53)
R 3 (#c1d452)
U 2 (#3e2a33)
R 5 (#c1d450)
U 5 (#0f6e43)
R 4 (#c65ae0)
U 3 (#790e83)
R 2 (#012b40)
U 7 (#2ea6b3)
R 4 (#358722)
D 2 (#7b3bf3)
R 6 (#adbd32)
D 4 (#4f7b63)
R 5 (#0d26f2)
U 5 (#47f363)
R 2 (#4c6160)
D 5 (#70ff63)
R 5 (#284290)
D 3 (#231103)
L 7 (#540e80)
D 2 (#8b51b3)
L 5 (#662c40)
D 4 (#22e7e3)
R 7 (#1d46a0)
D 3 (#343a43)
L 6 (#4d7d90)
D 4 (#31a643)
L 10 (#4e6b30)
U 4 (#31a641)
L 4 (#5abc90)
D 3 (#799953)
L 4 (#9e4ed0)
D 5 (#3b73e3)
R 7 (#390760)
D 3 (#bd3533)
L 7 (#390762)
D 5 (#075bd3)
L 3 (#1b7350)
D 3 (#a01d23)
R 4 (#a56752)
D 2 (#6a4313)
R 5 (#529462)
D 4 (#843c43)
R 4 (#829482)
U 4 (#7914e3)
R 3 (#2f0b90)
U 7 (#5f3d53)
R 6 (#114980)
D 7 (#60b7e3)
R 4 (#b9b2f0)
D 4 (#60b7e1)
R 5 (#2143f0)
D 3 (#2f86d3)
L 7 (#5f4440)
D 4 (#366293)
L 5 (#5baae0)
U 8 (#80a9a3)
L 3 (#61f680)
D 8 (#80a9a1)
L 5 (#8bdce0)
U 4 (#46e4d1)
L 5 (#120950)
D 8 (#7c15b1)
L 4 (#641450)
D 2 (#047bf1)
L 2 (#3b00c0)
D 7 (#a18c33)
L 3 (#543b70)
D 2 (#a18c31)
L 7 (#466150)
D 4 (#5c3ad1)
R 4 (#5caa80)
D 2 (#230201)
R 6 (#955102)
D 6 (#b200c1)
R 7 (#955100)
D 3 (#1d8ff1)
R 3 (#26f9d0)
D 8 (#160d71)
R 2 (#483920)
D 4 (#4577c3)
R 8 (#92ef90)
D 5 (#a57e83)
R 7 (#0715a0)
D 3 (#1da9e3)
L 2 (#627970)
D 6 (#573ee1)
L 8 (#006f30)
D 4 (#735da1)
L 4 (#006f32)
D 4 (#266951)
R 3 (#9745a0)
D 6 (#412bb1)
R 7 (#83f8f2)
D 2 (#6c4d31)
R 4 (#6a7e72)
D 3 (#578921)
L 7 (#6c5d92)
D 2 (#5485c1)
L 5 (#300852)
D 4 (#cdf091)
L 2 (#544dd2)
D 3 (#1259f1)
L 7 (#882292)
D 6 (#03e4b1)
R 7 (#cdf192)
D 3 (#5f3c41)
R 4 (#c836b0)
D 5 (#4cfdc1)
L 2 (#36a590)
D 4 (#244753)
L 2 (#73bd60)
D 3 (#244751)
L 7 (#72cc90)
U 4 (#0e0d21)
L 5 (#21ce60)
D 4 (#523dd1)
L 9 (#041252)
D 3 (#8cfc81)
R 5 (#041250)
D 5 (#365031)
R 6 (#21ce62)
U 5 (#17b3e1)
R 5 (#75a900)
D 3 (#8d4fe1)
R 4 (#75a902)
D 3 (#342091)
R 5 (#8d5570)
D 5 (#a6f9a3)
R 5 (#59f560)
D 4 (#49ae63)
R 5 (#59f562)
D 5 (#2dc6c3)
R 4 (#8fb550)
U 6 (#884bf3)
R 3 (#17ea50)
U 4 (#560143)
R 5 (#623ad0)
D 8 (#5dfc41)
R 5 (#ca0040)
D 2 (#5bc201)
R 4 (#ca0042)
D 3 (#7008b1)
R 7 (#b87530)
U 4 (#5e8821)
R 4 (#817080)
U 7 (#69e951)
R 2 (#518e30)
U 4 (#0e9831)
R 5 (#29ea82)
D 4 (#26f041)
R 9 (#6a1862)
D 4 (#8d3971)
L 4 (#6a1860)
D 4 (#215e71)
L 5 (#29ea80)
D 3 (#282e61)
R 3 (#bc6172)
D 8 (#17c4f1)
L 6 (#1abf10)
U 5 (#1a15e1)
L 3 (#2ed960)
D 5 (#24f4f3)
L 4 (#9d6b00)
D 6 (#24f4f1)
L 2 (#704c40)
D 4 (#45b0c1)
L 5 (#93a182)
D 6 (#53b3b1)
L 5 (#5f72d2)
U 6 (#76a9f1)
L 4 (#643b62)
D 3 (#3f41f1)
L 6 (#691122)
D 2 (#606491)
L 5 (#4c5b02)
D 5 (#6d1fa1)
L 2 (#bf6472)
D 6 (#6d1fa3)
L 6 (#989bb2)
U 4 (#606493)
L 3 (#348412)
U 6 (#9e4561)
L 4 (#9b1742)
U 8 (#42a901)
L 5 (#09f8f2)
U 3 (#63a8c3)
R 8 (#591640)
U 4 (#2dcda3)
L 8 (#591642)
U 4 (#4f7803)
L 2 (#3e5fe2)
U 5 (#0b9e93)
L 3 (#cae6b2)
U 4 (#7399f3)
L 7 (#28c482)
U 6 (#d2ee83)
L 3 (#28c480)
U 6 (#2f0423)
L 3 (#320f52)
U 2 (#5f4ab1)
L 4 (#8d6672)
U 6 (#b09261)
L 6 (#718952)
D 8 (#750591)
L 4 (#33df82)
D 5 (#1052a1)
L 4 (#9a90e2)
U 6 (#8eb861)
L 2 (#0c1e92)
U 4 (#53b871)
L 4 (#0739f2)
U 4 (#76cfb1)
L 6 (#9b6922)
U 7 (#76cfb3)
L 5 (#846eb2)
D 4 (#53b873)
L 3 (#6b7ae2)
D 4 (#59dd21)
L 2 (#60b0b2)
D 6 (#a53b01)
R 5 (#767632)
D 4 (#6c6bb1)
L 4 (#b3a932)
D 3 (#0660a1)
L 5 (#12b390)
U 4 (#9c9d01)
L 4 (#12b392)
U 3 (#910691)
L 4 (#8dec12)
U 6 (#65ba53)
L 3 (#1e02b2)
U 2 (#b05803)
L 2 (#1e02b0)
U 8 (#8a5d93)
L 2 (#3bea42)
U 5 (#032da3)
R 8 (#0aabc2)
U 3 (#4a0a13)
L 8 (#9f1c02)
U 4 (#58a0f3)
L 3 (#9f1c00)
D 3 (#3a2cf3)
L 7 (#169b22)
D 2 (#004253)
L 2 (#841fd2)
D 9 (#0b8473)
L 4 (#3f85a2)
D 6 (#134bd3)
L 2 (#17f832)
D 5 (#8870f3)
L 2 (#87cf62)
D 3 (#8b9fa3)
L 2 (#6ca082)
D 3 (#9a6ea3)
L 7 (#60cbc2)
D 4 (#9a6ea1)
L 2 (#296752)
D 3 (#b0d5c3)
L 8 (#0e0100)
D 5 (#218503)
L 6 (#36a620)
D 7 (#071463)
L 3 (#669dd0)
D 3 (#3099a1)
L 7 (#385d40)
D 5 (#3099a3)
L 7 (#3c66b0)
D 3 (#8fec33)
L 2 (#4ce142)
D 4 (#4b7051)
L 8 (#55b322)
D 3 (#4b7053)
L 7 (#38cd62)
D 3 (#668b13)
L 4 (#36a622)
D 2 (#581f83)
L 4 (#0e0102)
D 7 (#356bd3)
L 5 (#3eb472)
D 3 (#4ca003)
L 3 (#6afe62)
D 5 (#4ca001)
L 5 (#536dd2)
U 8 (#978bb3)
L 5 (#6118d2)
U 7 (#aec403)

14
day18/sample.txt Normal file
View File

@@ -0,0 +1,14 @@
R 6 (#70c710)
D 5 (#0dc571)
L 2 (#5713f0)
D 2 (#d2c081)
R 2 (#59c680)
D 2 (#411b91)
L 5 (#8ceee2)
U 2 (#caa173)
L 1 (#1b58a2)
U 2 (#caa171)
R 2 (#7807d2)
U 3 (#a77fa3)
L 2 (#015232)
U 2 (#7a21e3)

BIN
day19/c/day19 Executable file
View File

Binary file not shown.

303
day19/c/day19.c Normal file
View File

@@ -0,0 +1,303 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LINE_MAX_LENGTH 256
#define MAX_INSTRUCTIONS 16
#define MAX_WORKFLOWS 1024
#define MAX_PARTS 2048
#define NUM_0_CHARCODE 48
#define NUM_9_CHARCODE NUM_0_CHARCODE + 9
#define MAX_BREAKPOINTS 1024
typedef struct instruction {
char category;
char operator;
int value;
char destination[16];
int destination_length;
} instruction_t;
typedef struct workflow {
char name[16];
int name_length;
instruction_t instructions[MAX_INSTRUCTIONS];
int instructions_num;
char default_action[16];
int default_action_length;
} workflow_t;
typedef struct part {
int x;
int m;
int a;
int s;
} part_t;
typedef struct breakpoints {
int x[MAX_BREAKPOINTS];
int x_num;
int m[MAX_BREAKPOINTS];
int m_num;
int a[MAX_BREAKPOINTS];
int a_num;
int s[MAX_BREAKPOINTS];
int s_num;
} breakpoints_t;
int cmp(const void *a, const void *b);
char get_workflow_result(workflow_t workflows[], int workflows_num, part_t part, workflow_t in);
int main() {
char *p, *q, *buf, c;
buf = (char *)malloc(LINE_MAX_LENGTH);
memset(buf, 0, LINE_MAX_LENGTH);
p = buf;
int first = 1;
workflow_t *workflows = (workflow_t*)malloc(MAX_WORKFLOWS * sizeof(workflow_t));
memset(workflows, 0, MAX_WORKFLOWS * sizeof(workflow_t));
int workflows_num = 0;
part_t *parts = (part_t*)malloc(MAX_PARTS * sizeof(part_t));
memset(parts, 0, MAX_PARTS * sizeof(part_t));
int parts_num = 0;
while ((c = getchar()) != EOF) {
*p++ = c;
if (c == '\n') {
if (buf[0] == '\n') {
first = 0;
} else {
p = buf;
if (first) {
while (*p != '{') p++;
strncpy(workflows[workflows_num].name, buf, p - buf);
workflows[workflows_num].name_length = p - buf;
p++;
while(*p != '\n') {
q = p;
while(*p != '<' && *p != '>' && *p != '}') p++;
// Default action
if (*p == '}') {
strncpy(workflows[workflows_num].default_action, q, p - q);
workflows[workflows_num].default_action_length = p - q;
} else {
workflows[workflows_num].instructions[workflows[workflows_num].instructions_num].category = *q;
workflows[workflows_num].instructions[workflows[workflows_num].instructions_num].operator = *p;
p++;
sscanf(p, "%i", &workflows[workflows_num].instructions[workflows[workflows_num].instructions_num].value);
while (*p != ':') p++;
p++;
q = p;
while (*p != ',') p++;
strncpy(workflows[workflows_num].instructions[workflows[workflows_num].instructions_num].destination, q, p - q);
workflows[workflows_num].instructions[workflows[workflows_num].instructions_num].destination_length = p - q;
workflows[workflows_num].instructions_num++;
}
p++;
}
workflows_num++;
} else {
while (*p < NUM_0_CHARCODE || *p > NUM_9_CHARCODE) p++;
sscanf(p, "%i", &parts[parts_num].x);
while (*p != ',') p++;
while (*p < NUM_0_CHARCODE || *p > NUM_9_CHARCODE) p++;
sscanf(p, "%i", &parts[parts_num].m);
while (*p != ',') p++;
while (*p < NUM_0_CHARCODE || *p > NUM_9_CHARCODE) p++;
sscanf(p, "%i", &parts[parts_num].a);
while (*p != ',') p++;
while (*p < NUM_0_CHARCODE || *p > NUM_9_CHARCODE) p++;
sscanf(p, "%i", &parts[parts_num].s);
parts_num++;
}
}
memset(buf, 0, LINE_MAX_LENGTH);
p = buf;
}
}
// Find start
workflow_t *start;
for (int i = 0; i < workflows_num; i++) {
if (!strcmp(workflows[i].name, "in")) {
start = &workflows[i];
break;
}
}
int part1 = 0;
for (int i = 0; i < parts_num; i++) {
char result = get_workflow_result(workflows, workflows_num, parts[i], *start);
if (result == 'A') {
part1 += parts[i].x + parts[i].m + parts[i].a + parts[i].s;
}
}
printf("%i\n", part1);
breakpoints_t breakpoints;
memset(&breakpoints, 0, sizeof(breakpoints_t));
for (int i = 0; i < workflows_num; i++) {
for (int j = 0; j < workflows[i].instructions_num; j++) {
if (workflows[i].instructions[j].category == 'x') {
int value = workflows[i].instructions[j].operator == '<' ? workflows[i].instructions[j].value : workflows[i].instructions[j].value + 1;
int found = 0;
for (int k = 0; k < breakpoints.x_num; k++) {
if (breakpoints.x[k] == value) {
found = 1;
break;
}
}
if (!found) {
breakpoints.x[breakpoints.x_num] = value;
breakpoints.x_num++;
}
}
if (workflows[i].instructions[j].category == 'm') {
int value = workflows[i].instructions[j].operator == '<' ? workflows[i].instructions[j].value : workflows[i].instructions[j].value + 1;
int found = 0;
for (int k = 0; k < breakpoints.m_num; k++) {
if (breakpoints.m[k] == value) {
found = 1;
break;
}
}
if (!found) {
breakpoints.m[breakpoints.m_num] = value;
breakpoints.m_num++;
}
}
if (workflows[i].instructions[j].category == 'a') {
int value = workflows[i].instructions[j].operator == '<' ? workflows[i].instructions[j].value : workflows[i].instructions[j].value + 1;
int found = 0;
for (int k = 0; k < breakpoints.a_num; k++) {
if (breakpoints.a[k] == value) {
found = 1;
break;
}
}
if (!found) {
breakpoints.a[breakpoints.a_num] = value;
breakpoints.a_num++;
}
}
if (workflows[i].instructions[j].category == 's') {
int value = workflows[i].instructions[j].operator == '<' ? workflows[i].instructions[j].value : workflows[i].instructions[j].value + 1;
int found = 0;
for (int k = 0; k < breakpoints.s_num; k++) {
if (breakpoints.s[k] == value) {
found = 1;
break;
}
}
if (!found) {
breakpoints.s[breakpoints.s_num] = value;
breakpoints.s_num++;
}
}
}
}
qsort(breakpoints.x, breakpoints.x_num, sizeof(breakpoints.x[0]), &cmp);
qsort(breakpoints.m, breakpoints.m_num, sizeof(breakpoints.m[0]), &cmp);
qsort(breakpoints.a, breakpoints.a_num, sizeof(breakpoints.a[0]), &cmp);
qsort(breakpoints.s, breakpoints.s_num, sizeof(breakpoints.s[0]), &cmp);
double part2 = 0;
#pragma omp parallel for schedule(dynamic)
for (int i = 0; i < breakpoints.x_num + 1; i++) {
for (int j = 0; j < breakpoints.m_num + 1; j++) {
for (int k = 0; k < breakpoints.a_num + 1; k++) {
for (int l = 0; l < breakpoints.s_num + 1; l++) {
unsigned long x0 = i == 0 ? 1 : breakpoints.x[i - 1];
unsigned long x1 = i == breakpoints.x_num ? 4001 : breakpoints.x[i];
unsigned long m0 = j == 0 ? 1 : breakpoints.m[j - 1];
unsigned long m1 = j == breakpoints.m_num ? 4001 : breakpoints.m[j];
unsigned long a0 = k == 0 ? 1 : breakpoints.a[k - 1];
unsigned long a1 = k == breakpoints.a_num ? 4001 : breakpoints.a[k];
unsigned long s0 = l == 0 ? 1 : breakpoints.s[l - 1];
unsigned long s1 = l == breakpoints.s_num ? 4001 : breakpoints.s[l];
part_t metapart = {
.x = x0,
.m = m0,
.a = a0,
.s = s0,
};
char result = get_workflow_result(workflows, workflows_num, metapart, *start);
#pragma omp critical
if (result == 'A') {
part2 += (double)(x1 - x0) * (double)(m1 - m0) * (double)(a1 - a0) * (double)(s1 - s0);
}
}
}
}
}
printf("%f\n", part2);
free(buf);
free(workflows);
}
int cmp(const void *a, const void *b) {
return *(int*)a - *(int*)b;
}
char get_workflow_result(workflow_t workflows[], int workflows_num, part_t part, workflow_t in) {
for (int i = 0; i < in.instructions_num; i++) {
int value;
switch (in.instructions[i].category) {
case 'x':
value = part.x;
break;
case 'm':
value = part.m;
break;
case 'a':
value = part.a;
break;
case 's':
value = part.s;
break;
}
int matches;
switch (in.instructions[i].operator) {
case '<':
matches = value < in.instructions[i].value;
break;
case '>':
matches = value > in.instructions[i].value;
break;
}
if (matches) {
if (!strcmp(in.instructions[i].destination, "A")) {
return 'A';
}
if (!strcmp(in.instructions[i].destination, "R")) {
return 'R';
}
for (int j = 0; j < workflows_num; j++) {
if (!strcmp(workflows[j].name, in.instructions[i].destination)) {
return get_workflow_result(workflows, workflows_num, part, workflows[j]);
}
}
}
}
if (!strcmp(in.default_action, "A")) {
return 'A';
}
if (!strcmp(in.default_action, "R")) {
return 'R';
}
for (int i = 0; i < workflows_num; i++) {
if (!strcmp(workflows[i].name, in.default_action)) {
return get_workflow_result(workflows, workflows_num, part, workflows[i]);
}
}
return 'F';
}

769
day19/input.txt Normal file
View File

@@ -0,0 +1,769 @@
mxf{m<2310:phv,zs}
zjr{s>1167:zqt,skq}
hm{x>2975:rkl,x>2818:vhs,a>1062:bkc,kjg}
dkl{m>2321:ctj,x>3530:A,gj}
zk{s<1218:R,A}
zkd{m>864:A,a>488:R,jcp}
zdl{m>3429:A,m>2961:R,R}
xmd{a<576:A,a<1045:R,a<1386:R,A}
kzz{m>1106:R,a<508:R,x>2970:A,R}
gdr{x<139:R,x<183:A,s<222:A,R}
rb{m<3239:R,a<3546:A,A}
xns{x<621:vrz,gm}
nd{s>2927:xnx,x<3488:A,a<434:pg,A}
fl{s<3624:qg,m>952:qf,kjt}
vhm{x<3815:R,s>1774:A,m>643:R,A}
krp{a<2439:R,m>298:R,x<1440:R,R}
njj{x<2856:cjc,x<2936:R,a>598:R,kzz}
jp{m>1745:R,x<1239:A,a<625:lt,qbq}
rhd{a<3515:R,a<3543:A,s<3959:R,R}
htm{a>284:R,m<1961:R,s<2226:R,A}
kjj{a>704:fcn,s<439:lq,R}
jkk{s>1376:R,a<341:A,A}
jt{s<3384:A,x<3143:R,xgd}
bcm{a<1408:R,m<425:R,A}
hc{s>1126:A,m>1159:A,R}
jff{a>3411:A,s<804:jn,A}
knh{s>2643:szq,A}
klj{x>1392:A,a<2628:R,R}
kfx{a>1268:R,A}
cxd{a>1275:A,s>1768:R,R}
clq{a>1293:R,x>3243:R,R}
mpc{a<2362:R,R}
ng{a>578:A,x>1430:A,R}
hh{a>2697:A,s<1336:R,a<2167:A,A}
cjc{a<661:R,s>1113:A,x<2787:A,A}
fgv{m>3553:R,m<3400:A,m>3492:A,A}
pqk{m<110:R,A}
zqt{m<1713:mg,s>1555:jfx,s<1309:zm,A}
jrz{a<665:nh,tgp}
vsf{s<2496:R,R}
xdc{a>2214:R,A}
kkm{s>3217:A,x<3895:R,a<857:A,R}
sbh{s>1082:ct,sgx}
kcn{x<3313:A,x<3389:mmt,phd}
sgg{a<817:rf,s>2209:nhz,R}
jd{s>2746:R,a>2645:R,R}
pb{x>2553:A,qb}
hq{a<1200:A,a<1322:A,m<968:R,R}
kfz{x<3631:A,R}
fvf{a>917:drd,s>3325:qt,kcn}
ctj{m>2668:R,A}
tbl{x>2400:ql,m<2122:cs,m>2504:rq,tpp}
kn{m<1806:R,a<588:R,x>3133:R,A}
sv{a<1325:R,a>1460:R,m>1718:R,A}
rkl{x>3112:A,s>3342:R,R}
mg{m>1291:R,A}
tm{x>1917:bs,A}
rkq{a<2465:bxc,x>1862:nxc,sp}
tk{a<1228:A,a<1455:R,A}
vts{s>3466:jq,xns}
nh{x<2134:rr,x<2484:pbv,m<976:lvp,mv}
sz{x<3075:R,m>359:R,R}
btr{x>3197:qkh,ph}
ff{m>1946:A,s<2407:zc,A}
cmk{s>2606:R,A}
jr{a>804:A,a<475:R,R}
rf{x<415:A,s>2228:R,a<735:R,R}
drd{s>3365:tk,s<3276:bcm,A}
hvq{s<2401:hsn,s>3374:fl,xdl}
vpn{s<1325:fvm,m<689:R,R}
vj{s<1347:A,x>673:R,R}
tnz{s>999:A,x>2657:gk,A}
rft{a<401:pqp,qdm}
gkm{m>430:A,m>196:A,s>3374:R,A}
vhs{m>623:R,R}
zzt{x>3410:A,m>2991:R,m<2312:A,A}
pth{x<3816:A,s>3893:A,R}
vmd{s>3539:zr,gr}
dlh{x<3015:R,A}
lv{a<2026:A,m<292:R,x>588:R,A}
pr{x>3172:rjk,a<1192:R,m<595:A,A}
dzq{a<812:bgx,s>1212:nhn,nnd}
kxf{x>3058:R,A}
tgp{a>1311:kkg,a>960:jx,hmf}
npv{s<668:A,x>1167:A,R}
pd{a<1327:A,a<1446:rp,R}
krf{m>228:A,A}
cg{m<3308:nr,a>1054:fxs,cgf}
qd{a>2742:qmb,x>1719:mt,s>818:nrs,mpc}
bsc{x>1586:R,a<1207:R,R}
kcb{a<1236:A,s<1368:A,A}
mf{a<2852:zv,m<2664:prx,rb}
pnj{a<754:R,rcb}
zr{x>1721:A,x>683:R,x>265:R,A}
bn{s>1397:A,a<219:R,R}
hx{a>953:A,a>428:A,x>539:R,R}
jv{s<837:pr,fsl}
qmb{s<1185:R,A}
zcf{x>784:A,R}
jpf{s<2409:A,s<2671:A,x<1126:A,R}
kj{a>836:jv,x>3467:tjj,rl}
cnc{s<3455:A,s<3662:R,a>1191:A,R}
vbg{s>2501:R,x<3479:xhj,x>3748:R,R}
in{a>1666:mb,x<1861:dql,sl}
xg{x<749:dgs,A}
pj{m<830:R,R}
jb{m>3287:A,m>3057:gfh,A}
zdp{a>3403:R,a>3071:R,m>808:R,A}
ggc{x>1433:A,s>2595:R,R}
pxr{s<3463:R,m<792:R,A}
lk{x<724:R,s<3706:A,trm}
mjv{s<3762:A,bxn}
hl{a>556:ks,s<2836:A,m<1771:kc,kjd}
gf{x>1994:R,m<3457:xkg,s>3446:R,A}
bxz{m<718:R,A}
bv{s<2868:ggc,R}
pg{a<269:A,x>3764:R,m>3066:R,R}
vxn{s>1686:R,a>1312:R,m<2228:A,A}
jj{a>673:A,R}
zsx{x>3204:R,A}
cs{s<1229:A,R}
qdm{a<550:A,m>833:R,A}
vkl{s>365:A,x<236:gdr,s<161:zt,vxr}
cb{x<1464:A,x<1513:R,m<1814:R,R}
fn{m>2717:A,s>3698:A,R}
jzq{x>330:A,m>2865:R,A}
gn{a<1001:A,R}
cvv{m>817:fr,x<1974:mrv,m<316:vd,kh}
spl{a<1511:R,A}
qg{a<3083:csf,a>3444:mz,vmd}
tf{x>3535:R,a<669:gxm,s>2146:clq,A}
sg{s<463:lx,s<936:tq,R}
pnb{s<1080:R,m<3125:A,m<3446:A,R}
phd{x<3427:A,R}
hmf{a>804:gsn,s<1343:btv,vsf}
cdj{a>358:mdl,a<238:A,nk}
xs{x>2559:A,m>1333:A,A}
phv{m<2219:R,m<2257:R,x<565:A,A}
rx{s<2069:nvr,m>2736:qr,R}
vld{x>969:A,s>1063:A,m<689:R,A}
drn{s>1516:kx,m<611:kbn,jff}
jlg{s<2849:tgr,qlb}
nrn{a<1365:xmh,a>1565:A,x<1595:R,fgv}
fx{x>3184:R,a<1161:R,x<2964:A,R}
nfm{m<3293:R,m<3660:A,A}
cft{a<735:A,a>1165:jdq,m<1013:ctl,xdg}
grs{x<630:chb,bp}
tsq{s<3424:klj,s>3632:rkq,tj}
ll{a<566:R,R}
zc{m<1722:A,x>1506:A,x>1464:R,A}
tmx{s>3389:A,x>2770:A,R}
jdq{s>1592:A,R}
hhb{m<728:R,s<3217:bf,kfz}
chb{s>1613:A,A}
zcv{m<1690:A,a>1254:cb,R}
gdt{s<2338:R,a>529:R,A}
lrd{s>1816:A,s<1737:R,x>3648:vhm,mxs}
dl{s>1645:A,A}
rdr{m<3263:lmt,nrn}
dbp{x>1326:R,A}
vr{m<2215:R,A}
dqb{m>1367:A,s>3854:A,A}
mj{x<3291:xmd,m<1474:A,x>3594:fp,mk}
cvq{s<3167:vz,x>3484:dzt,m>1895:qsk,dj}
hrq{m>912:zn,s<2570:pk,x<3198:A,A}
tq{m<525:A,A}
cx{s>971:xbb,a>2286:R,s>558:lv,R}
vlz{s<432:bdx,m>419:R,m<201:fh,cm}
hsm{x>3894:psb,s>3500:A,zh}
pmv{m>1260:xn,x<1634:tkk,A}
mt{m<3482:lps,R}
qs{x>214:R,m<2255:A,A}
pf{m>399:R,x>3064:R,R}
fd{s>3477:A,R}
cmp{a>553:A,R}
gbx{s>657:R,m>939:A,m<824:A,A}
hsn{a>2953:drn,m>656:kzh,x<1575:xm,vpx}
vmr{a<696:A,m>594:R,s<2925:A,R}
hv{m>2584:R,m>2556:A,R}
gq{m<3154:A,x>3367:hmd,rsn}
tpc{x>3467:A,m>1865:A,m<1087:R,R}
vf{x>567:A,R}
xq{s>2490:ll,jj}
dx{m<213:mx,x<981:qtt,a<1191:A,ktx}
sq{s<518:jtt,a<1365:fbb,spl}
ds{m<1024:R,x<1332:A,A}
nn{m<337:srx,tx}
xf{a>645:cnc,R}
ltv{m<3188:cp,pt}
gjp{a<3444:R,A}
tbx{a>2651:bv,zx}
qf{a<3156:cmf,s>3778:gkk,x<1377:lk,jqq}
qdf{m>3031:A,s>3921:cqp,fg}
zx{s>2703:R,s<2561:gts,a>2305:A,snk}
xlj{a<240:R,R}
rl{x>3006:cdj,a>458:njj,vpn}
psq{a>939:tnp,m<1665:mnk,rpj}
bc{a<486:knh,m<3114:gth,lcr}
zq{x<1396:R,x<1668:A,R}
xm{x<973:cx,llb}
fzx{x>1946:A,x>1916:A,s>2523:dgq,bz}
gr{s<3443:A,R}
rsh{m<2322:A,R}
lzn{m<3606:A,m<3836:vql,a<423:R,R}
rsn{s<2344:A,a>1284:A,m<3610:A,A}
rg{m<752:A,s<3018:A,s<3072:R,R}
drs{a>2000:A,A}
ctl{s<1467:R,x>675:R,a<885:R,A}
fvm{a>168:A,s>868:R,R}
mtn{a>310:R,R}
rbt{x>3216:R,A}
dzt{m<1618:prn,zxd}
cp{x>616:A,m<2469:qs,R}
zkk{a>806:R,s<1275:A,a>636:A,R}
jrp{a>1285:A,A}
crv{m>183:R,x>1678:mbr,A}
mk{m>2781:R,x<3408:R,x<3508:A,A}
qvp{x<2839:R,s>2645:A,R}
tj{m>3041:jxs,m<2346:R,A}
gj{s<1310:R,R}
dd{a>700:dx,s<1439:xg,rfd}
ptj{m>919:cft,a<819:bq,grs}
qbq{a>1005:A,x>1477:A,A}
nmh{a>884:R,a>308:R,s<2046:R,hnp}
lx{a<901:A,m>593:R,R}
pqd{x>1493:A,x<1235:A,A}
bnh{m<1280:R,s<3302:R,R}
tv{a<332:zg,gdt}
rnd{a<1518:R,a>1596:A,A}
jlb{a>2132:R,s>736:R,x<1111:A,R}
mmz{x>992:R,a<1403:R,x<929:A,R}
qfp{m>1069:R,A}
pt{s>1650:vf,s>1452:R,x<446:A,vj}
tkk{s<1160:A,m>1174:R,a<673:R,A}
kx{x>2642:R,s<1888:A,R}
dq{x<1992:sc,x>2131:mjs,cmp}
xbb{s>1608:A,a<2166:A,s<1285:R,A}
btv{s>646:R,A}
br{a<1023:kxf,sds}
nr{m>2923:R,s>3647:R,m>2756:R,R}
nhn{x<1067:ltv,rdr}
mbr{x>3214:A,A}
mrv{m>400:R,m<212:A,A}
vpx{a>2478:tnz,s>821:nn,a<2119:vlz,vkv}
hn{x>2956:A,A}
jz{a<775:R,A}
pqp{m>731:A,A}
gbf{a>1519:pvj,m>715:gbx,rm}
mz{m>549:R,x<2243:krf,a>3781:R,jm}
gth{m>2216:brs,m>1852:xxk,a>662:R,A}
bmn{s<892:A,R}
pgh{s<2509:A,m<3134:R,R}
kqd{s<2377:A,A}
nhq{x>538:A,s<315:R,m<296:R,R}
zhr{m>2625:kqd,tp}
nrt{s<1274:A,x<1313:A,A}
mp{a>2286:jd,psr}
zn{m>1099:A,R}
vkv{m>221:pf,s<542:qm,m<110:A,A}
xdl{a<2851:nqc,s<2936:cvv,x>1808:kp,km}
kfs{a>1392:bcv,s>2659:A,R}
rcl{s>3400:R,m<528:A,R}
fsl{s>1571:cxd,m>988:jrp,A}
bd{m<486:R,R}
sr{x<445:A,zdl}
qt{s<3423:gkm,x<3311:A,m>745:R,bqz}
zfp{x>1123:nqq,A}
gbd{a>1434:A,x<2274:A,m>947:R,R}
kbn{x<1675:R,sz}
mb{m<1446:hvq,ch}
bcg{a>2036:A,a<1912:A,R}
mv{s<2113:jkk,s>2853:fd,xs}
dgq{a<1317:R,m>2464:R,m<2017:A,A}
dt{s<2641:R,m<702:A,R}
stf{m<199:A,R}
sh{m>261:R,a<915:A,R}
dv{a>2613:A,R}
zd{a<554:cdx,a<841:kjj,x<798:mlm,sg}
jn{a<3252:A,x<2123:R,A}
lvp{a>277:A,nf}
fh{m>123:R,A}
lt{x>1632:R,s<654:R,a<325:R,R}
lcr{a<720:A,m>3584:A,R}
jfx{s>1699:R,x>616:A,A}
hg{s<2617:xmj,a<850:R,s>2800:A,A}
vpd{m<2602:R,a<1388:R,x<2900:rnd,A}
mc{x<1595:A,x<1769:R,x>1809:A,A}
hnq{x>2458:A,s<1704:R,A}
bp{x<1089:A,x<1479:A,R}
lps{x>2602:R,A}
gmh{m<2825:R,A}
dmp{a<1343:dl,x<2089:A,x>2165:A,R}
bbg{x<415:A,m<580:A,a>1069:mdk,nj}
qlb{m<838:nl,m<1169:pq,x<799:pl,dxj}
ms{s<3815:hn,a<1068:lqt,qdf}
lh{s<885:vkl,m>1432:pn,a>1109:pd,vb}
fg{s<3875:R,m<2292:A,x>2987:A,R}
sgx{x>2162:R,x>2109:A,R}
fb{x>2219:bc,sx}
gh{a<2425:R,R}
zj{s<1096:xlj,R}
rc{a>1099:R,m>1634:jpf,x<1066:A,R}
lxp{a>1410:tpc,s>2961:qgx,R}
rsc{m<134:A,m>220:A,R}
xr{s<789:pj,m>812:hq,s<967:xvt,vld}
jq{a<892:zcf,m<3084:fn,R}
jx{m<668:bzx,a>1083:R,A}
ft{s>2537:R,x>3546:R,x>3014:A,pgh}
db{a<998:R,s<1612:R,x>2784:A,R}
vd{s>2660:pqk,a<3336:rsc,a>3760:hvb,A}
cn{s>2852:R,m>2099:rsh,dxk}
tjz{x<3743:R,s>3348:ssv,s>3252:R,kkm}
nlt{a<205:R,x>1400:R,a<276:A,A}
xvt{m>687:R,x<799:A,A}
hp{m>1850:hg,m<1700:rc,s>2663:hl,jr}
kch{m>1902:A,R}
llb{s<1505:R,x<1208:R,x>1337:krp,R}
tmk{x<647:tcj,x<1410:hp,x>1663:xq,cgj}
psj{x<2003:hnh,R}
szq{x<2455:A,x>2571:R,R}
nxc{s<3784:A,s<3926:A,x>3006:A,A}
ph{x>2866:ts,ngq}
zh{a>920:A,R}
md{x>809:hf,x<467:lh,zjr}
kd{a<1002:jt,x<3170:vpd,pfg}
sc{x<1928:A,a<406:R,m>2129:R,A}
vg{a<2146:R,m<798:R,s>1349:R,A}
clg{s<1574:A,A}
gd{a<1867:R,s>1838:R,m>3359:R,A}
dxk{a<463:A,s<2763:R,s<2797:R,R}
prx{a>3468:vk,m<2059:rbt,x>3171:hk,qvp}
fcn{x<1040:R,s>626:R,x<1572:A,A}
srx{m>147:R,m<80:A,R}
dzv{x>2236:zhr,a<1268:zll,tt}
bx{s>2165:A,x<3424:A,s<2155:A,R}
sx{m<2846:dq,s<2128:mq,s>3114:gf,lzn}
mmt{m>667:R,R}
zll{s>2412:sfz,x>2017:sbh,tm}
hnp{s>2072:R,R}
pl{x>413:R,m<1336:R,x<211:R,jz}
dr{a>1530:R,A}
qzf{s>2145:bx,a<1033:R,kfx}
rj{a<3192:A,s>3193:R,m>697:A,A}
fnd{x>449:A,s>115:R,R}
vk{m<2203:A,s>2735:R,x>3249:R,A}
vxh{m>559:bxz,x<777:R,R}
tpp{x<1376:hh,bmn}
nk{s<810:R,a>313:A,a>264:R,A}
nvr{s>792:A,x>1945:R,R}
zxd{x<3810:xf,m<2542:hsm,cg}
kz{s<606:R,m>1077:A,A}
bkc{x>2757:A,R}
xnx{m>3422:A,a>711:R,s<3019:R,A}
tjf{a<744:R,a>1261:A,a>1039:fx,zsx}
kc{m>1735:R,A}
tgr{x>786:xjb,bbg}
td{a>3522:xqd,x>2536:R,x<2142:dlg,rj}
zrh{m>1071:md,s<1184:kg,jrv}
gsn{a<885:A,a>912:R,R}
ldb{a>254:R,R}
qx{a>982:A,m<2418:R,R}
kp{s<3127:rg,s>3291:pb,x<3205:td,hhb}
rr{s<2162:R,R}
sj{m<572:R,A}
st{x<2946:A,x>3298:A,a<700:R,R}
sp{m<2339:R,s>3855:A,R}
zzx{m<3186:dm,xl}
bcv{s<2617:A,a>1559:R,x>1488:A,A}
xhj{s>2477:A,R}
fp{x>3859:R,R}
nx{m<1903:A,bsc}
gpf{m<821:A,m>1201:R,s<3661:R,R}
bxc{x>1591:R,A}
mx{m>85:R,R}
dql{s>1910:lpf,m>2088:dzq,zrh}
fvx{a<1533:A,A}
snb{m>1043:A,s<1569:vg,m<829:A,mh}
rp{x<289:A,A}
xxk{m<1974:A,s<1985:A,R}
qr{s<3186:A,a>1382:R,s>3578:A,A}
jrv{m<380:dd,m<830:hhr,ptj}
skq{x>635:A,hx}
rpj{s>3338:kn,a>391:A,R}
zs{m>2355:R,a>863:A,s<3650:A,A}
rvd{s>1220:R,s<494:jzq,s<762:nlj,A}
qm{x<2515:R,R}
sqt{a<1023:A,R}
lcl{m<2710:A,m<3464:R,m<3759:R,R}
gkk{s<3899:R,a>3581:A,a<3426:R,rhd}
fr{s<2683:njl,R}
nhz{a<947:A,m>1908:R,m>1673:A,A}
rlp{s<774:A,R}
bf{s<3175:A,R}
psr{x>1061:R,a<1875:A,x>357:R,A}
nqs{x<319:A,s<3699:A,x>463:kch,R}
fxs{s<3617:R,a<1444:A,A}
dxj{m>1297:gn,flt}
mhl{m>1106:R,s>1412:A,s<1288:R,R}
cgf{x<3874:R,m>3565:A,A}
qtt{x<603:A,m<300:R,x>743:R,R}
sd{x<3134:A,x>3645:qfp,x<3407:hc,R}
lpf{m>2444:cz,m<1547:jlg,s<3133:tmk,bt}
bbp{a>1097:lxp,m<2430:mvh,nd}
kkg{s>1504:fvx,s>961:gbd,x<2356:dr,A}
vxr{m<1531:A,m<1719:R,x<357:R,R}
mvh{m<1146:vmr,a<380:R,R}
csf{x>2650:pxr,a<2576:R,vv}
qzs{m<868:R,x<471:A,R}
sl{x<2677:hrh,s>1997:cvq,xpq}
hnh{s<2435:A,a<1516:A,a>1606:R,R}
bq{x<943:qzs,m>870:cr,mvd}
rq{a>2886:nrt,m>2662:gh,hv}
dm{a<495:mtn,a>678:bpt,ng}
mxs{a>470:R,x>3575:A,A}
gxm{m>1455:A,a>431:R,R}
bzx{a>1117:R,s<2331:A,A}
tcj{a>1108:jkx,s>2661:cn,a>647:sgg,htm}
zl{x<1326:R,a<186:R,A}
bqz{a>544:A,a<307:R,A}
xkg{x<1915:A,A}
cdx{a>339:rlp,x<772:A,a>152:npv,jk}
bz{a>1306:R,x<1884:R,x<1901:R,A}
hd{x>441:A,m>802:A,A}
kh{x>3037:R,cmk}
mn{a<482:A,A}
pk{s<2557:A,R}
nqq{a>559:A,s<3600:A,x>1458:A,R}
nrs{a>2275:R,a>2016:R,gd}
rpk{s<2091:nmh,s>2183:mj,m<2279:tf,qzf}
mlm{x<388:R,m>571:A,s<752:nhq,sh}
jxs{a>2736:A,R}
ks{x<974:A,a>1269:A,x>1159:R,R}
xmh{m<3623:A,m<3765:A,R}
hrh{m<1654:jrz,a<980:fb,dzv}
tp{m<2079:hnq,kcb}
fv{m>1406:ft,s<2551:vbg,hrq}
bpt{a<758:A,m<2540:A,R}
vql{x<1984:A,a>515:A,a<192:A,A}
bs{m>2823:A,A}
nf{m>644:R,R}
ssv{s<3440:A,A}
rfd{s<1718:clg,s>1797:stf,m<251:R,A}
lq{a>646:R,x>1191:R,R}
rv{a<531:zj,rvd}
tz{s>403:A,s>222:R,A}
gk{a<2728:R,x<3291:A,a>2857:R,R}
vjj{x>745:zfp,nqs}
cqp{x>2993:A,m<2484:R,a<1361:A,A}
xqd{s>3201:A,R}
cr{s>1438:A,a<283:A,x<1533:A,A}
xdg{s>1494:A,R}
xjb{s<2508:pqd,s>2732:xcm,s>2589:dt,ds}
nnd{a>1189:sq,dck}
brs{s<1860:A,x>2522:R,A}
jm{s<3472:A,m>227:A,m<99:A,A}
mh{m<948:A,m>1009:R,R}
lm{s<2631:A,A}
qgx{m>1733:A,a<1279:A,s>3061:R,A}
kjg{m>757:tmx,A}
njl{a<3412:R,s>2568:R,s>2458:R,A}
mnk{m>1403:phx,m>1317:R,a>417:st,bnh}
vb{a>478:zkk,bn}
tnp{x<3103:A,x>3353:dkv,m<1534:A,sv}
plz{a<2245:A,A}
hhr{s>1496:vxh,sj}
nv{m>3730:R,R}
km{x<978:hd,rqf}
dgs{m<245:A,s<1274:A,R}
tnb{s>3817:pth,x>3774:A,gpf}
cq{a<1034:mn,mmz}
dck{s>410:cxs,m<2779:qx,jb}
cm{a>1896:R,A}
kms{a>2292:R,x<1613:drs,m>1261:bcg,A}
bdx{m>310:R,s<240:A,s>356:R,A}
rqf{s>3178:A,zdp}
xmj{m>2206:A,R}
hf{m>1482:jp,x<1267:cq,pmv}
vv{s<3498:A,x>954:A,x>375:A,R}
bxn{m>622:A,x<3163:A,A}
lqt{m<3266:A,a<374:A,a<656:R,A}
kjd{a>215:R,A}
lvs{s<2888:lm,A}
jcz{x>988:xd,mxf}
bt{m<2092:vjj,jcz}
gm{a>795:A,m>3022:R,R}
prn{s>3549:tnb,tjz}
tjj{s<1166:zkd,s>1652:lrd,x<3663:sxt,rft}
tt{a>1417:psj,x>2002:dmp,a>1352:rx,fzx}
nj{m<1121:R,R}
qkh{m>3145:pnj,dkl}
ch{s>2396:dg,cv}
zm{x>625:A,x<542:A,m>1927:A,R}
lmt{m>2506:R,s<1559:R,m>2329:mc,vxn}
fbb{a<1249:R,s<765:A,R}
nlj{s<671:R,x<425:R,R}
frt{m<454:srz,a>1436:gbf,xr}
cv{m>2927:qd,tbl}
vz{s>2596:bbp,s<2247:rpk,s>2462:fv,ssd}
pbv{s>1407:ldb,s>929:A,kz}
bgx{x<941:rv,zzx}
pfg{x>3349:zzt,nfm}
ssd{m<2231:tjf,a>683:gq,tv}
cmf{s<3771:xj,m<1213:plz,dqb}
qsk{s<3510:kd,ms}
mjs{s<1429:A,A}
dj{s>3501:br,m>1254:psq,x<3181:hm,fvf}
hmd{m<3500:R,m>3704:R,A}
tx{x>2397:R,x<1870:A,s<1560:A,R}
ts{a<1021:A,x>2977:R,lcl}
sfz{m>2706:A,s>3253:A,A}
vrz{m>3406:R,m<2945:A,A}
psb{x>3943:R,R}
hvb{m>189:A,m<82:R,A}
xk{x<1541:dbp,m<3333:xpg,s<2457:R,nv}
jkx{s<2566:R,A}
trm{a>3458:A,A}
xl{a>319:A,m>3484:zl,nlt}
mvd{a>391:A,m>852:R,A}
mdk{m<1132:R,m>1384:A,R}
ql{a>2685:dlh,xdc}
tg{x>1137:xk,sr}
xcm{s>2808:A,R}
dkv{m>1597:A,a<1295:R,m>1451:A,A}
pq{x>685:zq,A}
hcq{m<1264:A,a>3456:R,x<3097:R,R}
gfh{a<942:R,s>187:A,m>3151:A,R}
nqc{m>952:kms,m<498:crv,x<1886:mp,lvs}
zv{a<2363:A,s>2848:A,dv}
kg{a<990:zd,frt}
sxt{x>3571:mhl,s>1399:R,R}
rcb{s>831:R,R}
ct{m<2782:R,x<2144:R,R}
jk{x>1280:R,a<62:R,a<97:A,A}
xpg{s<2389:R,x>1653:R,x>1605:A,A}
rm{s>756:R,s<272:A,A}
zt{m<1571:R,x>357:R,s<90:R,R}
kzh{x>2664:sd,s<1123:jlb,snb}
hk{a>3113:A,m<2299:R,R}
xgd{s>3436:A,s<3413:A,m<2980:A,R}
xn{a<733:A,x>1650:R,a<1166:A,R}
zg{a>211:R,R}
phx{m>1520:R,s<3316:R,A}
nl{x>1066:rcl,R}
gts{a<2156:R,A}
cz{s<3196:tg,vts}
flt{x<1306:R,m>1253:A,s<3466:R,R}
mq{m<3476:R,a>643:R,m>3779:A,zk}
xpq{m>1741:btr,kj}
dlg{s<3232:R,s>3262:R,R}
jcp{m<292:A,x<3654:A,a<245:A,A}
sds{a>1440:A,x<3037:R,A}
kjt{x<2493:bd,mjv}
xd{x>1460:R,vr}
dg{s>3110:tsq,x>2350:mf,tbx}
snk{a>2064:A,m>2299:R,A}
xj{s<3720:R,a>2638:A,A}
cgj{a<890:ff,x>1546:nx,m<1898:zcv,kfs}
srz{a>1345:A,A}
pn{s<1253:A,R}
ktx{a<1448:A,a<1571:A,A}
mdl{s<786:R,m<811:A,A}
jqq{s>3703:gjp,hcq}
rjk{s>459:A,x>3536:A,A}
cxs{s>846:pnb,s>638:R,A}
jtt{s>281:gmh,x<928:fnd,s<175:A,A}
ngq{s>979:db,x<2798:tz,m>2572:R,sqt}
qb{m>669:R,A}
pvj{m>712:R,x>690:R,a>1577:R,A}
{x=396,m=612,a=2012,s=177}
{x=39,m=25,a=812,s=272}
{x=1930,m=15,a=99,s=905}
{x=373,m=1162,a=3153,s=1794}
{x=1045,m=108,a=1143,s=639}
{x=2178,m=621,a=580,s=172}
{x=1292,m=1910,a=122,s=2528}
{x=275,m=192,a=83,s=2992}
{x=2218,m=157,a=99,s=545}
{x=822,m=2795,a=82,s=150}
{x=2178,m=12,a=1672,s=1504}
{x=2463,m=620,a=882,s=1746}
{x=1025,m=1370,a=21,s=45}
{x=3161,m=944,a=884,s=1590}
{x=285,m=849,a=595,s=2630}
{x=423,m=480,a=177,s=2385}
{x=2022,m=777,a=1166,s=371}
{x=195,m=1446,a=1622,s=727}
{x=1831,m=1163,a=710,s=98}
{x=2054,m=767,a=416,s=462}
{x=814,m=1038,a=1871,s=118}
{x=2109,m=136,a=69,s=265}
{x=30,m=745,a=2265,s=2135}
{x=92,m=1923,a=1269,s=62}
{x=2952,m=875,a=82,s=199}
{x=1527,m=550,a=926,s=34}
{x=84,m=1894,a=1418,s=3020}
{x=1419,m=2050,a=2634,s=992}
{x=19,m=1722,a=207,s=2292}
{x=122,m=3195,a=179,s=979}
{x=970,m=3603,a=193,s=1431}
{x=515,m=681,a=501,s=459}
{x=682,m=2621,a=1754,s=649}
{x=1972,m=2722,a=215,s=2720}
{x=358,m=2273,a=248,s=1091}
{x=103,m=468,a=48,s=467}
{x=111,m=251,a=199,s=55}
{x=1536,m=541,a=1850,s=1349}
{x=318,m=1491,a=1124,s=1821}
{x=2441,m=1571,a=981,s=1207}
{x=639,m=2165,a=588,s=658}
{x=704,m=1423,a=2397,s=1207}
{x=51,m=161,a=833,s=1036}
{x=375,m=188,a=1668,s=681}
{x=141,m=744,a=732,s=77}
{x=341,m=1182,a=1040,s=249}
{x=265,m=873,a=281,s=1691}
{x=1022,m=37,a=1865,s=338}
{x=1580,m=137,a=283,s=1031}
{x=1361,m=1432,a=1179,s=2447}
{x=617,m=1360,a=305,s=54}
{x=235,m=733,a=60,s=2192}
{x=362,m=181,a=1297,s=835}
{x=133,m=132,a=1327,s=64}
{x=573,m=263,a=741,s=98}
{x=799,m=898,a=2180,s=732}
{x=186,m=517,a=681,s=1168}
{x=47,m=2806,a=3577,s=578}
{x=3218,m=1130,a=1204,s=414}
{x=2468,m=2891,a=900,s=2094}
{x=215,m=1069,a=1689,s=1228}
{x=372,m=937,a=725,s=412}
{x=1434,m=1549,a=1539,s=1007}
{x=3222,m=841,a=1854,s=1272}
{x=2326,m=1637,a=1918,s=30}
{x=1248,m=266,a=750,s=2521}
{x=110,m=1288,a=364,s=749}
{x=752,m=803,a=257,s=316}
{x=1777,m=1615,a=942,s=110}
{x=227,m=1524,a=1800,s=309}
{x=105,m=246,a=1723,s=3455}
{x=713,m=1172,a=833,s=804}
{x=3026,m=39,a=376,s=71}
{x=946,m=3437,a=1461,s=149}
{x=1878,m=303,a=207,s=1081}
{x=2982,m=2510,a=14,s=3078}
{x=818,m=1042,a=943,s=958}
{x=2349,m=7,a=802,s=822}
{x=140,m=473,a=2454,s=3331}
{x=1014,m=796,a=1453,s=348}
{x=1578,m=2615,a=539,s=294}
{x=993,m=276,a=564,s=2618}
{x=2908,m=327,a=705,s=1430}
{x=46,m=361,a=291,s=1076}
{x=2267,m=212,a=952,s=365}
{x=677,m=2277,a=550,s=1061}
{x=226,m=1391,a=653,s=2321}
{x=1654,m=15,a=27,s=421}
{x=974,m=241,a=255,s=283}
{x=202,m=84,a=1805,s=81}
{x=337,m=529,a=254,s=42}
{x=765,m=2055,a=473,s=413}
{x=1731,m=81,a=370,s=133}
{x=2839,m=739,a=513,s=990}
{x=376,m=660,a=924,s=65}
{x=627,m=1486,a=1422,s=2326}
{x=2688,m=2,a=659,s=347}
{x=1388,m=1650,a=1875,s=363}
{x=305,m=1406,a=1285,s=50}
{x=1095,m=382,a=2098,s=1120}
{x=1172,m=402,a=1935,s=1646}
{x=27,m=357,a=714,s=355}
{x=42,m=45,a=217,s=1134}
{x=22,m=415,a=624,s=358}
{x=324,m=3057,a=221,s=3288}
{x=540,m=179,a=1033,s=568}
{x=7,m=999,a=453,s=316}
{x=231,m=428,a=1092,s=8}
{x=2221,m=3036,a=22,s=735}
{x=247,m=516,a=339,s=1756}
{x=3140,m=2229,a=1643,s=2012}
{x=1248,m=500,a=624,s=779}
{x=1245,m=1806,a=579,s=2269}
{x=989,m=442,a=671,s=419}
{x=266,m=1547,a=992,s=664}
{x=1078,m=24,a=1069,s=1848}
{x=908,m=1979,a=1027,s=956}
{x=78,m=719,a=1328,s=105}
{x=901,m=601,a=3503,s=1239}
{x=949,m=851,a=356,s=1086}
{x=315,m=565,a=1868,s=857}
{x=1426,m=1398,a=918,s=1629}
{x=1286,m=2229,a=500,s=16}
{x=360,m=481,a=2006,s=991}
{x=1514,m=2442,a=1921,s=183}
{x=2155,m=1924,a=616,s=986}
{x=2121,m=1323,a=352,s=958}
{x=756,m=2750,a=543,s=2608}
{x=833,m=168,a=2410,s=232}
{x=3,m=810,a=451,s=40}
{x=1151,m=452,a=1642,s=965}
{x=560,m=2062,a=2265,s=846}
{x=1,m=246,a=905,s=323}
{x=1642,m=193,a=448,s=25}
{x=86,m=486,a=588,s=75}
{x=2360,m=5,a=417,s=2689}
{x=676,m=947,a=402,s=355}
{x=1869,m=44,a=944,s=1139}
{x=36,m=1033,a=588,s=391}
{x=63,m=31,a=608,s=817}
{x=1115,m=2098,a=617,s=702}
{x=2117,m=848,a=2371,s=3170}
{x=270,m=2617,a=393,s=330}
{x=325,m=3377,a=870,s=1077}
{x=275,m=139,a=876,s=648}
{x=657,m=231,a=2197,s=915}
{x=1934,m=1410,a=1965,s=1574}
{x=251,m=841,a=480,s=24}
{x=771,m=479,a=107,s=2259}
{x=1364,m=166,a=27,s=664}
{x=774,m=303,a=909,s=93}
{x=264,m=164,a=3471,s=176}
{x=681,m=2247,a=1660,s=837}
{x=1348,m=204,a=990,s=219}
{x=650,m=1469,a=1269,s=1160}
{x=1121,m=534,a=2270,s=927}
{x=322,m=1871,a=693,s=170}
{x=540,m=462,a=929,s=99}
{x=3015,m=915,a=808,s=3661}
{x=248,m=383,a=471,s=106}
{x=1536,m=1350,a=2067,s=804}
{x=1656,m=56,a=1629,s=995}
{x=17,m=236,a=288,s=218}
{x=663,m=1611,a=317,s=1272}
{x=630,m=2397,a=1538,s=805}
{x=211,m=2,a=137,s=514}
{x=2340,m=191,a=173,s=618}
{x=2154,m=6,a=42,s=884}
{x=526,m=1292,a=694,s=1722}
{x=606,m=355,a=1532,s=1351}
{x=1405,m=543,a=126,s=3}
{x=548,m=429,a=1382,s=572}
{x=95,m=1008,a=1790,s=42}
{x=1796,m=1272,a=188,s=201}
{x=1437,m=3161,a=754,s=4}
{x=891,m=447,a=1389,s=145}
{x=183,m=894,a=821,s=1455}
{x=457,m=79,a=1586,s=1179}
{x=1631,m=828,a=2697,s=73}
{x=56,m=506,a=1988,s=448}
{x=3408,m=971,a=2130,s=1899}
{x=347,m=1915,a=193,s=1460}
{x=308,m=3,a=1189,s=191}
{x=2,m=354,a=2761,s=287}
{x=634,m=864,a=101,s=233}
{x=632,m=91,a=1935,s=202}
{x=27,m=1364,a=2765,s=2}
{x=367,m=510,a=473,s=132}
{x=987,m=2516,a=1834,s=1121}
{x=626,m=845,a=176,s=265}
{x=577,m=823,a=2129,s=23}
{x=802,m=295,a=389,s=226}
{x=844,m=301,a=549,s=126}
{x=1139,m=235,a=9,s=1183}
{x=663,m=2444,a=554,s=1516}
{x=1244,m=355,a=252,s=1023}
{x=151,m=2238,a=392,s=93}
{x=99,m=1911,a=362,s=1272}
{x=71,m=146,a=46,s=1359}
{x=1140,m=650,a=75,s=1458}

17
day19/sample.txt Normal file
View File

@@ -0,0 +1,17 @@
px{a<2006:qkq,m>2090:A,rfg}
pv{a>1716:R,A}
lnx{m>1548:A,A}
rfg{s<537:gd,x>2440:R,A}
qs{s>3448:A,lnx}
qkq{x<1416:A,crn}
crn{x>2662:A,R}
in{s<1351:px,qqz}
qqz{s>2770:qs,m<1801:hdj,R}
gd{a>3333:R,R}
hdj{m>838:A,pv}
{x=787,m=2655,a=1222,s=2876}
{x=1679,m=44,a=2067,s=496}
{x=2036,m=264,a=79,s=2244}
{x=2461,m=1339,a=466,s=291}
{x=2127,m=1623,a=2188,s=1013}

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
day22/c/day22 Executable file
View File

Binary file not shown.

140
day22/c/day22.c Normal file
View File

@@ -0,0 +1,140 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <omp.h>
#define LINE_MAX_LENGTH 256
#define MAX_BRICKS 2048
#define NUM_0_CHARCODE 48
#define NUM_9_CHARCODE NUM_0_CHARCODE + 9
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) < (b) ? (a) : (b))
#define in_range(c,a,b) ((c) <= max(a,b) && (c) >= min(a,b))
typedef struct corner {
int x;
int y;
int z;
} corner_t;
typedef struct brick {
corner_t corners[2];
int fallen;
} brick_t;
int fall(brick_t bricks[], int bricks_num);
int intersect(brick_t brick_a, brick_t brick_b);
int main() {
char *p, *buf, c;
buf = (char *)malloc(LINE_MAX_LENGTH);
memset(buf, 0, LINE_MAX_LENGTH);
p = buf;
brick_t bricks[MAX_BRICKS];
int bricks_num = 0;
while ((c = getchar()) != EOF) {
*p++ = c;
if (c == '\n') {
p = buf;
sscanf(p, "%i", &bricks[bricks_num].corners[0].x);
while (*p != ',') p++;
p++;
sscanf(p, "%i", &bricks[bricks_num].corners[0].y);
while (*p != ',') p++;
p++;
sscanf(p, "%i", &bricks[bricks_num].corners[0].z);
while (*p != '~') p++;
p++;
sscanf(p, "%i", &bricks[bricks_num].corners[1].x);
while (*p != ',') p++;
p++;
sscanf(p, "%i", &bricks[bricks_num].corners[1].y);
while (*p != ',') p++;
p++;
sscanf(p, "%i", &bricks[bricks_num].corners[1].z);
bricks_num++;
memset(buf, 0, LINE_MAX_LENGTH);
p = buf;
}
}
while (fall(bricks, bricks_num));
for (int i = 0; i < bricks_num; i++) {
bricks[i].fallen = 0;
}
int part1 = 0;
int part2 = 0;
#pragma omp parallel for schedule(dynamic)
for (int i = 0; i < bricks_num; i++) {
brick_t bricks_copy[MAX_BRICKS];
memcpy(bricks_copy, bricks, sizeof(bricks));
bricks_copy[i].corners[0].z = 0;
bricks_copy[i].corners[1].z = 0;
int fallen = 0;
while (fall(bricks_copy, bricks_num));
for (int j = 0; j < bricks_num; j++) {
fallen += bricks_copy[j].fallen;
}
#pragma omp critical
{
if (fallen == 0) {
part1++;
}
part2 += fallen;
}
}
printf("%i\n", part1);
printf("%i\n", part2);
free(buf);
}
int fall(brick_t bricks[], int bricks_num) {
int result = 0;
for (int i = 0; i < bricks_num; i++) {
int fallen = 0;
for (;;) {
bricks[i].corners[0].z--;
bricks[i].corners[1].z--;
if (bricks[i].corners[0].z <= 0 || bricks[i].corners[1].z <= 0) {
break;
}
int collision = 0;
for (int j = 0; j < bricks_num; j++) {
if (i == j) continue;
if (intersect(bricks[i], bricks[j])) {
collision = 1;
break;
}
}
if (collision) {
break;
}
bricks[i].fallen = 1;
fallen = 1;
}
bricks[i].corners[0].z++;
bricks[i].corners[1].z++;
result += fallen;
}
return result;
}
int intersect(brick_t brick_a, brick_t brick_b) {
if (
(in_range(brick_b.corners[0].x, brick_a.corners[0].x, brick_a.corners[1].x) || in_range(brick_b.corners[1].x, brick_a.corners[0].x, brick_a.corners[1].x) || in_range(brick_a.corners[1].x, brick_b.corners[0].x, brick_b.corners[1].x) || in_range(brick_a.corners[0].x, brick_b.corners[0].x, brick_b.corners[1].x)) &&
(in_range(brick_b.corners[0].y, brick_a.corners[0].y, brick_a.corners[1].y) || in_range(brick_b.corners[1].y, brick_a.corners[0].y, brick_a.corners[1].y) || in_range(brick_a.corners[1].y, brick_b.corners[0].y, brick_b.corners[1].y) || in_range(brick_a.corners[0].y, brick_b.corners[0].y, brick_b.corners[1].y)) &&
(in_range(brick_b.corners[0].z, brick_a.corners[0].z, brick_a.corners[1].z) || in_range(brick_b.corners[1].z, brick_a.corners[0].z, brick_a.corners[1].z) || in_range(brick_a.corners[1].z, brick_b.corners[0].z, brick_b.corners[1].z) || in_range(brick_a.corners[0].z, brick_b.corners[0].z, brick_b.corners[1].z))
) {
return 1;
}
return 0;
}

1439
day22/input.txt Normal file
View File

File diff suppressed because it is too large Load Diff

7
day22/sample.txt Normal file
View File

@@ -0,0 +1,7 @@
1,0,1~1,2,1
0,0,2~2,0,2
0,2,3~2,2,3
0,0,4~0,2,4
2,0,5~2,2,5
0,1,6~2,1,6
1,1,8~1,1,9

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###
#.....###...###...#...#
#####################.#