diff options
author | Marvin Borner | 2020-12-05 14:17:52 +0100 |
---|---|---|
committer | Marvin Borner | 2020-12-05 14:28:58 +0100 |
commit | aac336b3596b1eb5e6819fec70302858cda3c683 (patch) | |
tree | 13305b12a6ba34e13c2cc062fbf9bf792fe9285b | |
parent | 24091cc157b1f32458bee8200dc302f906c4d4de (diff) |
Added 5th solution
-rw-r--r-- | 2020/5/Makefile | 10 | ||||
-rw-r--r-- | 2020/5/input | 960 | ||||
-rw-r--r-- | 2020/5/solve.c | 103 |
3 files changed, 1073 insertions, 0 deletions
diff --git a/2020/5/Makefile b/2020/5/Makefile new file mode 100644 index 0000000..769d06d --- /dev/null +++ b/2020/5/Makefile @@ -0,0 +1,10 @@ +.PHONY: solve.c + +solve.o: solve.c + @gcc $+ -o $@ + +clean: + @rm -f *.o + +run: solve.o + @./solve.o diff --git a/2020/5/input b/2020/5/input new file mode 100644 index 0000000..9d33385 --- /dev/null +++ b/2020/5/input @@ -0,0 +1,960 @@ +BFBBBBBLLR +BBFFBBFRRL +FBFBFFFRRL +BBFFFBFRRL +BFFBFBFRLL +FFBBBFBLRL +BFFFBFFLLR +FBFFFFBLRR +FBFFBBBRRR +BFFBFFFLLR +BFFFFFBLLL +FFBBFFBLRR +BFFFFFBRLR +FBFBFBFLLL +FFBFBFFLLL +BBFFFFFLLL +FFFBBBFLLL +BBFFBFBLLR +FFBFBFBRRR +BFFBFFFRRR +BBFFBFBRLR +FFFBFBFLRL +BBFFBBBLRR +FBBFFFFLLR +BBBFBBFLLL +BFFFFBBRLL +FBBFBFBRRL +FFBBBFFRRR +BBFFFFBRRR +FBBBBFFLLR +BFFFFFBLRR +FFBBFBFLLR +BFFBFBBLLL +BBFBBBBLLL +FBFBBBFRLL +FFBFFFBLRL +FFFFBBBLRL +BBBBFBFRRR +FFBBFBBRLL +FFFBBBBRRL +FFBFFFBRLR +BFBFBFBLLL +FFFBFFBLLL +BBFBFBBLRL +BBBBBFFLLL +FBBBBFFRRR +FBFFFFBLLL +FF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FBBFBFFLLL +FBFFBFFRLR +BFFBFFFLRL +FBFFBFFLLR +FBFBBBBRLL +BBFFFBFLRL +BBFBBFBLRR +BFFFFBBLRL +BBFBFBFLRL +FBBFBBBRLL +FBBFFFFRLL +FFBFBBBLLL +FFBFFBBLLR +BFBBBFFLLR +BBBFBFFRLR +BFFBFFFRRL +BBFFBBBRLL +BBFFBBFRLL +FBBBBBBLLR +BFFBFBBRRR +BBFFFBBRRL +FFBFFFFRLL +FFFBFBBLRR +BBFFBFBRRL +BBFFFBBLRL +FBFFFFBLRL +BFFFFBFRLL +BFFBBBFLLL +BFBBFBFRRL +FBBFFFBLRR +FFBFFFFRLR +FBBFFFFLLL +FBFBBFFRRR +FBFBBFFLLR +FFBFFFBRRL +BFBBBBFRLL +BFFBBBFLRL +FBFFBFBRRL +FFBFFFFLRR +FBBBFBBRLL +BBFBBBFRRR +BFFBFFFRLL +FFFBBFFRRL +BFBFFFBLLR +FBFFFBFRLR +FBFBBBFLLL +FFBBFBFRRL +BBBFBFFRLL +FBFFBFFLRR +BBFBBBFLRR +FFBBBFBLRR +FFFBFFFRLR +FBFBFFBLLL +BFBBBFFLLL +BFFFFBBLRR +FBFBBBFLLR +FBFFBBFLRR +FFBBFBBRRL +BBFBFFFLRR +BBFFBFFRRL +FFBBFFFLLL +FFBFBFFRRL +BBBFBFBRLR +BFBFFFBRLR +FBFBBBBLLL +FFBBBBBRLL +FBBFBBBLLL +BFFFBBFRRR +BFBFFBFRLR +BBBFFFFRLR +FBFFBBFRLL +FFBBFBFRLR +BFFBFBBRLL +BFBFBFFRRR +FBBFFFBRLL diff --git a/2020/5/solve.c b/2020/5/solve.c new file mode 100644 index 0000000..025b644 --- /dev/null +++ b/2020/5/solve.c @@ -0,0 +1,103 @@ +#include <stdio.h> +#include <stdlib.h> + +#define COUNT 1024 +#define FIRST 100 +#define LAST 1000 + +int row(char *s) +{ + int low = 0; + int high = 128; + for (char *p = s; *p && *p != 'R' && *p != 'L'; p++) { + if (*p == 'F') { + high -= 2 << (5 - (p - s)); + } else if (*p == 'B') { + low += 2 << (5 - (p - s)); + } + } + return low; +} + +int col(char *s) +{ + int low = 0; + int high = 8; + for (char *p = s + 7; *(p + 1); p++) { + if (*p == 'L') { + high -= 2 << (1 - (p - (s + 7))); + } else if (*p == 'R') { + low += 2 << (1 - (p - (s + 7))); + } + } + if (*(s + 9) == 'R') + return high - 1; + else if (*(s + 9) == 'L') + return low; + else + return 0; +} + +int compare(const void *a, const void *b) +{ + int int_a = *((int *)a); + int int_b = *((int *)b); + + if (int_a == int_b) + return 0; + else if (int_a < int_b) + return -1; + else + return 1; +} + +static int ids[COUNT] = { 0 }; + +int part_one(FILE *fp) +{ + int res = 0; + + char *line = NULL; + size_t len = 0; + int i = 0; + while (getline(&line, &len, fp) != -1) { + int id = row(line) * 8 + col(line); + if (id > res) + res = id; + + ids[i] = id; + i++; + } + + return res; +} + +int part_two() +{ + int res = 0; + + qsort(ids, COUNT, sizeof(int), compare); + + for (int i = 1; i < COUNT - 1; ++i) { + if (ids[i] == 0) + continue; + + if (ids[i] != ids[i + 1] && ids[i] != ids[i - 1] && i > FIRST && i < LAST) + res = ids[i]; + } + + return res; +} + +int main(int argc, char *argv[]) +{ + FILE *fp = fopen("input", "r"); + if (!fp) + exit(EXIT_FAILURE); + + printf("%d\n", part_one(fp)); + printf("%d\n", part_two()); + + fclose(fp); + return 0; +} |