diff options
author | Marvin Borner | 2021-11-30 21:53:46 +0100 |
---|---|---|
committer | Marvin Borner | 2021-11-30 21:53:46 +0100 |
commit | 3aa641542918765f6ceb039cfa64ff6f58597eb2 (patch) | |
tree | b665282b581d22c4189c57286ff8625a708f60a9 | |
parent | f0566aee824569b8cd20186b40c9b9be53f9261a (diff) |
Hype for tomorrow
-rw-r--r-- | 2015/01/Makefile | 17 | ||||
-rw-r--r-- | 2015/01/solve.c | 7 | ||||
-rw-r--r-- | 2015/02/Makefile | 19 | ||||
-rw-r--r-- | 2015/02/input | 1000 | ||||
-rw-r--r-- | 2015/02/solve.c | 65 | ||||
-rw-r--r-- | 2015/03/Makefile | 19 | ||||
-rw-r--r-- | 2015/03/input | 1 | ||||
-rw-r--r-- | 2015/03/solve.c | 97 | ||||
-rw-r--r-- | 2015/04/Makefile | 19 | ||||
-rw-r--r-- | 2015/04/input | 1 | ||||
-rw-r--r-- | 2015/04/solve.c | 118 | ||||
-rw-r--r-- | 2015/05/Makefile | 19 | ||||
-rw-r--r-- | 2015/05/input | 1000 | ||||
-rw-r--r-- | 2015/05/solve.c | 105 | ||||
-rw-r--r-- | template/c/Makefile | 19 | ||||
-rw-r--r-- | template/c/input | 0 | ||||
-rw-r--r-- | template/c/solve.c | 58 |
17 files changed, 2558 insertions, 6 deletions
diff --git a/2015/01/Makefile b/2015/01/Makefile index 769d06d..57e1574 100644 --- a/2015/01/Makefile +++ b/2015/01/Makefile @@ -1,10 +1,19 @@ -.PHONY: solve.c +DEBUG = -Wno-error -Og -ggdb3 -s -fsanitize=undefined -fsanitize=address -fstack-protector-all +CFLAGS = -Wall -Wextra -Werror -Wshadow -Wpointer-arith -Wwrite-strings -Wredundant-decls -Wnested-externs -Wformat=2 -Wmissing-declarations -Wstrict-prototypes -Wmissing-prototypes -Wcast-qual -Wswitch-default -Wswitch-enum -Wunreachable-code -Wundef -Wold-style-definition -Wvla -pedantic-errors -Ofast -solve.o: solve.c - @gcc $+ -o $@ +# Not the best makefile but idc + +debug: + @gcc $(CFLAGS) $(DEBUG) solve.c -o solve.o + +build: + @gcc $(CFLAGS) solve.c -o solve.o clean: @rm -f *.o -run: solve.o +run: debug + @./solve.o + +time: build @./solve.o diff --git a/2015/01/solve.c b/2015/01/solve.c index 287bf3f..81a0ec4 100644 --- a/2015/01/solve.c +++ b/2015/01/solve.c @@ -2,7 +2,7 @@ #include <stdlib.h> #include <time.h> -int part_one(FILE *fp) +static int part_one(FILE *fp) { int res = 0; @@ -17,7 +17,7 @@ int part_one(FILE *fp) return res; } -int part_two(FILE *fp) +static int part_two(FILE *fp) { int res = 0, floor = 0; @@ -39,6 +39,9 @@ int part_two(FILE *fp) int main(int argc, char *argv[]) { + (void)argc; + (void)argv; + FILE *fp = fopen("input", "r"); if (!fp) exit(EXIT_FAILURE); diff --git a/2015/02/Makefile b/2015/02/Makefile new file mode 100644 index 0000000..57e1574 --- /dev/null +++ b/2015/02/Makefile @@ -0,0 +1,19 @@ +DEBUG = -Wno-error -Og -ggdb3 -s -fsanitize=undefined -fsanitize=address -fstack-protector-all +CFLAGS = -Wall -Wextra -Werror -Wshadow -Wpointer-arith -Wwrite-strings -Wredundant-decls -Wnested-externs -Wformat=2 -Wmissing-declarations -Wstrict-prototypes -Wmissing-prototypes -Wcast-qual -Wswitch-default -Wswitch-enum -Wunreachable-code -Wundef -Wold-style-definition -Wvla -pedantic-errors -Ofast + +# Not the best makefile but idc + +debug: + @gcc $(CFLAGS) $(DEBUG) solve.c -o solve.o + +build: + @gcc $(CFLAGS) solve.c -o solve.o + +clean: + @rm -f *.o + +run: debug + @./solve.o + +time: build + @./solve.o diff --git a/2015/02/input b/2015/02/input new file mode 100644 index 0000000..908022e --- /dev/null +++ b/2015/02/input @@ -0,0 +1,1000 @@ +3x11x24 +13x5x19 +1x9x27 +24x8x21 +6x8x17 +19x18x22 +10x9x12 +12x2x5 +26x6x11 +9x23x15 +12x8x17 +13x29x10 +28x18x6 +22x28x26 +1x5x11 +29x26x12 +8x28x29 +27x4x21 +12x7x16 +7x4x23 +15x24x8 +15x14x2 +11x6x29 +28x19x9 +10x3x1 +5x20x13 +10x25x1 +22x17x7 +16x29x3 +18x22x8 +18x11x19 +21x24x20 +4x7x17 +22x27x12 +1x26x6 +5x27x24 +29x21x3 +25x30x2 +21x26x2 +10x24x27 +10x16x28 +18x16x23 +6x5x26 +19x12x20 +6x24x25 +11x20x7 +4x8x5 +2x13x11 +11x17x1 +13x24x6 +22x29x16 +4x24x20 +10x25x10 +12x29x23 +23x27x12 +11x21x9 +13x2x6 +15x30x2 +8x26x24 +24x7x30 +22x22x8 +29x27x8 +28x23x27 +13x16x14 +9x28x20 +21x4x30 +21x20x20 +11x17x30 +9x14x22 +20x2x6 +10x11x14 +1x8x23 +23x19x19 +26x10x13 +21x12x12 +25x7x24 +1x28x17 +20x23x9 +2x24x27 +20x24x29 +1x3x10 +5x20x14 +25x21x3 +15x5x22 +14x17x19 +27x3x18 +29x23x19 +14x21x19 +20x8x3 +22x27x12 +24x15x18 +9x10x19 +29x25x28 +14x22x6 +4x19x28 +4x24x14 +17x19x17 +7x19x29 +28x8x26 +7x20x16 +11x26x29 +2x18x3 +12x7x18 +11x15x21 +24x7x26 +2x22x23 +2x30x5 +1x19x8 +15x29x10 +15x26x22 +20x16x14 +25x29x22 +3x13x19 +1x12x30 +3x15x27 +19x9x11 +30x8x21 +26x12x20 +11x17x19 +17x25x1 +19x24x12 +30x6x20 +11x19x18 +18x15x29 +18x8x9 +25x15x5 +15x6x26 +13x27x19 +23x24x12 +3x15x28 +17x10x10 +15x4x7 +15x27x7 +21x8x11 +9x18x2 +7x20x20 +17x23x12 +2x19x1 +7x26x26 +13x23x8 +10x3x12 +11x1x9 +1x11x19 +25x14x26 +16x10x15 +7x6x11 +8x1x27 +20x28x17 +3x25x9 +30x7x5 +17x17x4 +23x25x27 +23x8x5 +13x11x1 +15x10x21 +22x16x1 +12x15x28 +27x18x26 +25x18x5 +21x3x27 +15x25x5 +29x27x19 +11x10x12 +22x16x21 +11x8x18 +6x10x23 +21x21x2 +13x27x28 +2x5x20 +23x16x20 +1x21x7 +22x2x13 +11x10x4 +7x3x4 +19x2x5 +21x11x1 +7x27x26 +12x4x23 +12x3x15 +25x7x4 +20x7x15 +16x5x11 +1x18x26 +11x27x10 +17x6x24 +19x13x16 +6x3x11 +4x19x18 +16x15x15 +1x11x17 +19x11x29 +18x19x1 +1x25x7 +8x22x14 +15x6x19 +5x30x18 +30x24x22 +11x16x2 +21x29x19 +20x29x11 +27x1x18 +20x5x30 +12x4x28 +3x9x30 +26x20x15 +18x25x18 +20x28x28 +21x5x3 +20x21x25 +19x27x22 +8x27x9 +1x5x15 +30x6x19 +16x5x15 +18x30x21 +4x15x8 +9x3x28 +18x15x27 +25x11x6 +17x22x15 +18x12x18 +14x30x30 +1x7x23 +27x21x12 +15x7x18 +16x17x24 +11x12x19 +18x15x21 +6x18x15 +2x21x4 +12x9x14 +19x7x25 +22x3x1 +29x19x7 +30x25x7 +6x27x27 +5x13x9 +21x4x18 +13x1x16 +11x21x25 +27x20x27 +14x25x9 +23x11x15 +22x10x26 +15x16x4 +14x16x21 +1x1x24 +17x27x3 +25x28x16 +12x2x29 +9x19x28 +12x7x17 +6x9x19 +15x14x24 +25x21x23 +26x27x25 +7x18x13 +15x10x6 +22x28x2 +15x2x14 +3x24x18 +30x22x7 +18x27x17 +29x18x7 +20x2x4 +4x20x26 +23x30x15 +5x7x3 +4x24x12 +24x30x20 +26x18x17 +6x28x3 +29x19x29 +14x10x4 +15x5x23 +12x25x4 +7x15x19 +26x21x19 +18x2x23 +19x20x3 +3x13x9 +29x21x24 +26x13x29 +30x27x4 +20x10x29 +21x18x8 +7x26x10 +29x16x21 +22x5x11 +17x15x2 +7x29x5 +6x18x15 +23x6x14 +10x30x14 +26x6x16 +24x13x25 +17x29x20 +4x27x19 +28x12x11 +23x20x3 +22x6x20 +29x9x19 +10x16x22 +30x26x4 +29x26x11 +2x11x15 +1x3x30 +30x30x29 +9x1x3 +30x13x16 +20x4x5 +23x28x11 +24x27x1 +4x25x10 +9x3x6 +14x4x15 +4x5x25 +27x14x13 +20x30x3 +28x15x25 +5x19x2 +10x24x29 +29x30x18 +30x1x25 +7x7x15 +1x13x16 +23x18x4 +1x28x8 +24x11x8 +22x26x19 +30x30x14 +2x4x13 +27x20x26 +16x20x17 +11x12x13 +28x2x17 +15x26x13 +29x15x25 +30x27x9 +2x6x25 +10x26x19 +16x8x23 +12x17x18 +26x14x22 +13x17x4 +27x27x29 +17x13x22 +9x8x3 +25x15x20 +14x13x16 +8x7x13 +12x4x21 +27x16x15 +6x14x5 +28x29x17 +23x17x25 +10x27x28 +1x28x21 +18x2x30 +25x30x16 +25x21x7 +2x3x4 +9x6x13 +19x6x10 +28x17x8 +13x24x28 +24x12x7 +5x19x5 +18x10x27 +16x1x6 +12x14x30 +1x2x28 +23x21x2 +13x3x23 +9x22x10 +10x17x2 +24x20x11 +30x6x14 +28x1x16 +24x20x1 +28x7x7 +1x24x21 +14x9x7 +22x8x15 +20x1x21 +6x3x7 +7x26x14 +5x7x28 +5x4x4 +15x7x28 +30x16x23 +7x26x2 +1x2x30 +24x28x20 +5x17x28 +4x15x20 +15x26x2 +1x3x23 +22x30x24 +9x20x16 +7x15x2 +6x21x18 +21x21x29 +29x10x10 +4x3x23 +23x2x18 +29x24x14 +29x29x16 +22x28x24 +21x18x24 +16x21x6 +3x9x22 +9x18x4 +22x9x9 +12x9x13 +18x21x14 +7x8x29 +28x28x14 +1x6x24 +11x11x3 +8x28x6 +11x16x10 +9x16x16 +6x6x19 +21x5x12 +15x17x12 +3x6x29 +19x1x26 +10x30x25 +24x26x21 +1x10x18 +6x1x16 +4x17x27 +17x11x27 +15x15x21 +14x23x1 +8x9x30 +22x22x25 +20x27x22 +12x7x9 +9x26x19 +26x25x12 +8x8x16 +28x15x10 +29x18x2 +25x22x6 +4x6x15 +12x18x4 +10x3x20 +17x28x17 +14x25x13 +14x10x3 +14x5x10 +7x7x22 +21x2x14 +1x21x5 +27x29x1 +6x20x4 +7x19x23 +28x19x27 +3x9x18 +13x17x17 +18x8x15 +26x23x17 +10x10x13 +11x5x21 +25x15x29 +6x23x24 +10x7x2 +19x10x30 +4x3x23 +22x12x6 +11x17x16 +6x8x12 +18x20x11 +6x2x2 +17x4x11 +20x23x22 +29x23x24 +25x11x21 +22x11x15 +29x3x9 +13x30x5 +17x10x12 +10x30x8 +21x16x17 +1x5x26 +22x15x16 +27x7x11 +16x8x18 +29x9x7 +25x4x17 +10x21x25 +2x19x21 +29x11x16 +18x26x21 +2x8x20 +17x29x27 +25x27x4 +14x3x14 +25x29x29 +26x18x11 +8x24x28 +7x30x24 +12x30x22 +29x20x6 +3x17x1 +6x15x14 +6x22x20 +13x26x26 +12x2x1 +7x14x12 +15x16x11 +3x21x4 +30x17x29 +9x18x27 +11x28x16 +22x3x25 +18x15x15 +2x30x12 +3x27x22 +10x8x8 +26x16x14 +15x2x29 +12x10x7 +21x20x15 +2x15x25 +4x14x13 +3x15x13 +29x8x3 +7x7x28 +15x10x24 +23x15x5 +5x7x14 +24x1x22 +1x11x13 +26x4x19 +19x16x26 +5x25x5 +17x25x14 +23x7x14 +24x6x17 +5x13x12 +20x20x5 +22x29x17 +11x17x29 +25x6x4 +29x8x16 +28x22x24 +24x23x17 +16x17x4 +17x8x25 +22x9x13 +24x4x8 +18x10x20 +21x23x21 +13x14x12 +23x26x4 +4x10x29 +2x18x18 +19x5x21 +2x27x23 +6x29x30 +21x9x20 +6x5x16 +25x10x27 +5x29x21 +24x14x19 +19x11x8 +2x28x6 +19x25x6 +27x1x11 +6x8x29 +18x25x30 +4x27x26 +8x12x1 +7x17x25 +7x14x27 +12x9x5 +14x29x13 +18x17x5 +23x1x3 +28x5x13 +3x2x26 +3x7x11 +1x8x7 +12x5x4 +2x30x21 +16x30x11 +3x26x4 +16x9x4 +11x9x22 +23x5x6 +13x20x3 +4x3x2 +14x10x29 +11x8x12 +26x15x16 +7x17x29 +18x19x18 +8x28x4 +22x6x13 +9x23x7 +11x23x20 +13x11x26 +15x30x13 +1x5x8 +5x10x24 +22x25x17 +27x20x25 +30x10x21 +16x28x24 +20x12x8 +17x25x1 +30x14x9 +14x18x6 +8x28x29 +12x18x29 +9x7x18 +6x12x25 +20x13x24 +22x3x12 +5x23x22 +8x10x17 +7x23x5 +10x26x27 +14x26x19 +10x18x24 +8x4x4 +16x15x11 +3x14x9 +18x5x30 +29x12x26 +16x13x12 +15x10x7 +18x5x26 +14x1x6 +10x8x29 +3x4x9 +19x4x23 +28x17x23 +30x7x17 +19x5x9 +26x29x28 +22x13x17 +28x2x1 +20x30x8 +15x13x21 +25x23x19 +27x23x1 +4x6x23 +29x29x24 +5x18x7 +4x6x30 +17x15x2 +27x4x2 +25x24x14 +28x8x30 +24x29x5 +14x30x14 +10x18x19 +15x26x22 +24x19x21 +29x23x27 +21x10x16 +7x4x29 +14x21x3 +21x4x28 +17x16x15 +24x7x13 +21x24x15 +25x11x16 +10x26x13 +23x20x14 +20x29x27 +14x24x14 +14x23x12 +18x6x5 +3x18x9 +8x18x19 +20x26x15 +16x14x13 +30x16x3 +17x13x4 +15x19x30 +20x3x8 +13x4x5 +12x10x15 +8x23x26 +16x8x15 +22x8x11 +12x11x18 +28x3x30 +15x8x4 +13x22x13 +21x26x21 +29x1x15 +28x9x5 +27x3x26 +22x19x30 +4x11x22 +21x27x20 +22x26x7 +19x28x20 +24x23x16 +26x12x9 +13x22x9 +5x6x23 +20x7x2 +18x26x30 +3x6x28 +24x18x13 +28x19x16 +25x21x25 +25x19x23 +22x29x10 +29x19x30 +4x7x27 +5x12x28 +8x26x6 +14x14x25 +17x17x2 +5x27x11 +8x2x2 +3x20x24 +26x10x9 +22x28x27 +18x15x20 +12x11x1 +5x14x30 +7x3x16 +2x16x16 +18x20x15 +13x14x29 +1x17x12 +13x5x23 +19x4x10 +25x19x11 +15x17x14 +1x28x27 +11x9x28 +9x10x18 +30x11x22 +21x21x20 +2x1x5 +2x25x1 +7x3x4 +22x15x29 +21x28x15 +12x12x4 +21x30x6 +15x10x7 +10x14x6 +21x26x18 +14x25x6 +9x7x11 +22x3x1 +1x16x27 +1x14x23 +2x13x8 +14x19x11 +21x26x1 +4x28x13 +12x16x20 +21x13x9 +3x4x13 +14x9x8 +21x21x12 +27x10x17 +6x20x6 +28x23x23 +2x28x12 +8x10x10 +3x9x2 +20x3x29 +19x4x16 +29x24x9 +26x20x8 +15x28x26 +18x17x10 +7x22x10 +20x15x9 +6x10x8 +7x26x21 +8x8x16 +15x6x29 +22x30x11 +18x25x8 +6x21x20 +7x23x25 +8x25x26 +11x25x27 +22x18x23 +3x2x14 +16x16x1 +15x13x11 +3x9x25 +29x25x24 +9x15x1 +12x4x1 +23x30x20 +3x1x23 +6x10x29 +28x13x24 +4x19x17 +6x6x25 +27x29x17 +12x13x2 +10x7x13 +14x15x8 +22x2x3 +27x17x19 +23x10x16 +5x9x25 +9x25x14 +11x18x6 +18x10x12 +9x4x15 +7x16x14 +17x24x10 +11x4x6 +12x9x17 +22x18x12 +6x24x24 +6x22x23 +5x17x30 +6x9x5 +17x20x10 +6x8x12 +14x17x13 +29x10x17 +22x4x5 +10x19x30 +22x29x11 +10x12x29 +21x22x26 +16x6x25 +1x26x24 +30x17x16 +27x28x5 +30x13x22 +7x26x12 +11x24x30 +1x17x25 +22x1x3 +29x24x6 +4x8x24 +13x9x20 +8x12x9 +21x25x4 +23x23x28 +5x2x19 +29x3x15 +22x1x14 +3x23x30 +8x25x3 +15x8x14 +30x14x6 +23x27x24 +19x1x2 +10x9x13 +13x8x7 +8x13x22 +5x15x20 +17x14x8 +5x11x20 +5x10x27 +24x17x19 +21x2x3 +15x30x26 +21x19x15 +2x7x23 +13x17x25 +30x15x19 +26x4x10 +2x25x8 +9x9x10 +2x25x8 +19x21x30 +17x26x12 +7x5x10 +2x22x14 +10x17x30 +1x8x5 +23x2x25 +22x29x8 +13x26x1 +26x3x30 +25x17x8 +25x18x26 +26x19x15 +8x28x10 +12x16x29 +30x6x29 +28x19x4 +27x26x18 +15x23x17 +5x21x30 +8x11x13 +2x26x7 +19x9x24 +3x22x23 +6x7x18 +4x26x30 +13x25x20 +17x3x15 +8x20x18 +23x18x23 +28x23x9 +16x3x4 +1x29x14 +20x26x22 +3x2x22 +23x8x17 +19x5x17 +21x18x20 +17x21x8 +30x28x1 +29x19x23 +12x12x11 +24x18x7 +21x18x14 +14x26x25 +9x11x3 +10x7x15 +27x6x28 +14x26x4 +28x4x1 +22x25x29 +6x26x6 +1x3x13 +26x22x12 +6x21x26 +23x4x27 +26x13x24 +5x24x28 +22x16x7 +3x27x24 +19x28x2 +11x13x9 +29x16x22 +30x10x24 +14x14x22 +22x23x16 +14x8x3 +20x5x14 +28x6x13 +3x15x25 +4x12x22 +15x12x25 +10x11x24 +7x7x6 +8x11x9 +21x10x29 +23x28x30 +8x29x26 +16x27x11 +1x10x2 +24x20x16 +7x12x28 +28x8x20 +14x10x30 +1x19x6 +4x12x20 +18x2x7 +24x18x17 +16x11x10 +1x12x22 +30x16x28 +18x12x11 +28x9x8 +23x6x17 +10x3x11 +5x12x8 +22x2x23 +9x19x14 +15x28x13 +27x20x23 +19x16x12 +19x30x15 +8x17x4 +10x22x18 +13x22x4 +3x12x19 +22x16x23 +11x8x19 +8x11x6 +7x14x7 +29x17x29 +21x8x12 +21x9x11 +20x1x27 +1x22x11 +5x28x4 +26x7x26 +30x12x18 +29x11x20 +3x12x15 +24x25x17 +14x6x11 diff --git a/2015/02/solve.c b/2015/02/solve.c new file mode 100644 index 0000000..e1030a8 --- /dev/null +++ b/2015/02/solve.c @@ -0,0 +1,65 @@ +#include <stdio.h> +#include <stdlib.h> +#include <time.h> + +static int part_one(FILE *fp) +{ + int res = 0; + + char *line = NULL; + size_t len = 0; + while (getline(&line, &len, fp) != EOF) { + int w, l, h; + sscanf(line, "%dx%dx%d", &w, &l, &h); + res += 2 * l * w + 2 * w * h + 2 * h * l; + + int a = w * l, b = l * h, c = w * h; + res += (a <= b && a <= c) ? a : (b <= c && b <= a) ? b : (c <= a && c <= b) ? c : 0; + } + + if (line) + free(line); + + return res; +} + +static int part_two(FILE *fp) +{ + int res = 0; + + char *line = NULL; + size_t len = 0; + while (getline(&line, &len, fp) != EOF) { + int w, l, h; + sscanf(line, "%dx%dx%d", &w, &l, &h); + + int a = 2 * w + 2 * l, b = 2 * l + 2 * h, c = 2 * w + 2 * h; + res += (a <= b && a <= c) ? a : (b <= c && b <= a) ? b : (c <= a && c <= b) ? c : 0; + res += w * h * l; + } + + if (line) + free(line); + + return res; +} + +int main(int argc, char *argv[]) +{ + (void)argc; + (void)argv; + + FILE *fp = fopen("input", "r"); + if (!fp) + exit(EXIT_FAILURE); + + clock_t tic = clock(); + printf("%d\n", part_one(fp)); + rewind(fp); + printf("%d\n", part_two(fp)); + clock_t toc = clock(); + printf("TIME: %f seconds\n", (double)(toc - tic) / CLOCKS_PER_SEC); + + fclose(fp); + return 0; +} diff --git a/2015/03/Makefile b/2015/03/Makefile new file mode 100644 index 0000000..57e1574 --- /dev/null +++ b/2015/03/Makefile @@ -0,0 +1,19 @@ +DEBUG = -Wno-error -Og -ggdb3 -s -fsanitize=undefined -fsanitize=address -fstack-protector-all +CFLAGS = -Wall -Wextra -Werror -Wshadow -Wpointer-arith -Wwrite-strings -Wredundant-decls -Wnested-externs -Wformat=2 -Wmissing-declarations -Wstrict-prototypes -Wmissing-prototypes -Wcast-qual -Wswitch-default -Wswitch-enum -Wunreachable-code -Wundef -Wold-style-definition -Wvla -pedantic-errors -Ofast + +# Not the best makefile but idc + +debug: + @gcc $(CFLAGS) $(DEBUG) solve.c -o solve.o + +build: + @gcc $(CFLAGS) solve.c -o solve.o + +clean: + @rm -f *.o + +run: debug + @./solve.o + +time: build + @./solve.o diff --git a/2015/03/input b/2015/03/input new file mode 100644 index 0000000..e69cd4f --- /dev/null +++ b/2015/03/input @@ -0,0 +1 @@ +^^<<v<<v><v^^<><>^^<v<v^>>^^^><^>v^>v><><><<vv^^<^>^^<v^>v>v^v>>>^<>v<^<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v<><v<vv><<>v<^<^>v<>v^>v>^^<<<^^vv^<><<<>>v>^^<>v>>>><v<v<^^^v<v<v^><<>v^v<>v>><<<<v^<><^<<^>^<vvv<v^^v>>v^vv^><^v^^<>^^><<v^>>vv>^<v^vv<^^v<>>vvv<^v^>>^<v<v>>^>^^<<^>^>^v><>>^<^^v>^>>^^<><>>>^^>^^vvv>v<^^<>v^v^^<v<<^<v^v^<<>v^v<v<<v<>>><<^^^>>v>^vv>^>^^v<>^^<>v^^<><v<v<vvv^<vv<<>v^><<><v<>vv<<^vvvv><<<v>v>v^>v^<>v^>^<v<vvv^>^<>^>^^v<>><<<><v<^^>^v<v>^^v^v<<<^v^<>^<>v>^^>v<v<v>v>^^<<<><<^>v<v<^vv^v><^^<<vv>^<<v><>^>>>>><v^v<<<^>^v^v<<v<>vvv<<>v>v>>^v^v^>><<<<>v^<v<><<>>>^>>^>><<v> diff --git a/2015/03/solve.c b/2015/03/solve.c new file mode 100644 index 0000000..8f4e9ad --- /dev/null +++ b/2015/03/solve.c @@ -0,0 +1,97 @@ +#include <stdio.h> +#include <stdlib.h> +#include <time.h> + +#define FORLINE \ + char *line = NULL; \ + size_t len = 0; \ + while (getline(&line, &len, fp) != EOF) +#define FREELINE \ + if (line) \ + free(line) + +#define FORCH \ + char ch = 0; \ + while ((ch = fgetc(fp)) != EOF) + +#define INFINITE 1024 +static int part_one(FILE *fp) +{ + int res = 1; + char houses[INFINITE * 2][INFINITE * 2] = { 0 }; + int x = INFINITE, y = INFINITE; + + houses[x][y] = 1; + FORCH + { + if (ch == '>') + x++; + else if (ch == '<') + x--; + else if (ch == '^') + y++; + else if (ch == 'v') + y--; + + if (!houses[x][y]) { + houses[x][y] = 1; + res++; + } + } + + return res; +} + +static int part_two(FILE *fp) +{ + int res = 1; + + char houses[INFINITE * 2][INFINITE * 2] = { 0 }; + int rx = INFINITE, ry = INFINITE, sx = INFINITE, sy = INFINITE; + + houses[sx][sy] = 1; + int robo = 0; + FORCH + { + int *x = robo ? &rx : &sx; + int *y = robo ? &ry : &sy; + + if (ch == '>') + (*x)++; + else if (ch == '<') + (*x)--; + else if (ch == '^') + (*y)++; + else if (ch == 'v') + (*y)--; + + if (!houses[*x][*y]) { + houses[*x][*y] = 1; + res++; + } + + robo = !robo; + } + + return res; +} + +int main(int argc, char *argv[]) +{ + (void)argc; + (void)argv; + + FILE *fp = fopen("input", "r"); + if (!fp) + exit(EXIT_FAILURE); + + clock_t tic = clock(); + printf("%d\n", part_one(fp)); + rewind(fp); + printf("%d\n", part_two(fp)); + clock_t toc = clock(); + printf("TIME: %f seconds\n", (double)(toc - tic) / CLOCKS_PER_SEC); + + fclose(fp); + return 0; +} diff --git a/2015/04/Makefile b/2015/04/Makefile new file mode 100644 index 0000000..f757e4a --- /dev/null +++ b/2015/04/Makefile @@ -0,0 +1,19 @@ +DEBUG = -Wno-error -Og -g -s -fsanitize=undefined -fsanitize=address -fstack-protector-all +CFLAGS = -Wall -Wextra -Werror -Wshadow -Wpointer-arith -Wwrite-strings -Wredundant-decls -Wnested-externs -Wformat=2 -Wmissing-declarations -Wstrict-prototypes -Wmissing-prototypes -Wcast-qual -Wswitch-default -Wswitch-enum -Wunreachable-code -Wundef -Wold-style-definition -Wvla -pedantic-errors -Ofast + +# Not the best makefile but idc + +debug: + @gcc $(CFLAGS) $(DEBUG) solve.c -o solve.o + +build: + @gcc $(CFLAGS) solve.c -o solve.o + +clean: + @rm -f *.o + +run: debug + @./solve.o + +time: build + @./solve.o diff --git a/2015/04/input b/2015/04/input new file mode 100644 index 0000000..0f84c61 --- /dev/null +++ b/2015/04/input @@ -0,0 +1 @@ +iwrupvqb diff --git a/2015/04/solve.c b/2015/04/solve.c new file mode 100644 index 0000000..94246d4 --- /dev/null +++ b/2015/04/solve.c @@ -0,0 +1,118 @@ +#include <limits.h> +#include <openssl/md5.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +#define FORLINE \ + char *line = NULL; \ + size_t len = 0; \ + while (getline(&line, &len, fp) != EOF) +#define FREELINE \ + if (line) \ + free(line) + +#define FORCH \ + char ch = 0; \ + while ((ch = fgetc(fp)) != EOF) + +#define WHOLE \ + fseek(fp, 0, SEEK_END); \ + long fsize = ftell(fp); \ + fseek(fp, 0, SEEK_SET); \ + char *data = malloc(fsize + 1); \ + fread(data, 1, fsize, fp); \ + data[fsize] = 0; \ + data[fsize--] = 0 + +#define FREEWHOLE free(data) + +static int part_one(FILE *fp) +{ + int res = 0; + + WHOLE; + + char *string = malloc(fsize + 64); + strcpy(string, data); + + while (1) { + res++; + + int cnt = sprintf(string + fsize, "%d", res); + + char out[64] = { 0 }; + unsigned char *hash = + MD5((unsigned char *)string, fsize + cnt, (unsigned char *)out); + /* for (int i = 0; i < 16; i++) */ + /* printf("%02x", hash[i]); */ + /* putchar('\n'); */ + + int sum = 0; + for (int i = 0; i < 2; i++) + sum += hash[i]; + sum += hash[2] & 0xf0; + if (sum == 0) + break; + } + + free(string); + FREEWHOLE; + + return res; +} + +static int part_two(FILE *fp) +{ + int res = 0; + + WHOLE; + + char *string = malloc(fsize + 64); + strcpy(string, data); + + while (1) { + res++; + + int cnt = sprintf(string + fsize, "%d", res); + + char out[64] = { 0 }; + unsigned char *hash = + MD5((unsigned char *)string, fsize + cnt, (unsigned char *)out); + /* for (int i = 0; i < 16; i++) */ + /* printf("%02x", hash[i]); */ + /* putchar('\n'); */ + + int sum = 0; + for (int i = 0; i < 3; i++) + sum += hash[i]; + if (sum == 0) + break; + } + + free(string); + FREEWHOLE; + + return res; +} + +int main(int argc, char *argv[]) +{ + (void)argc; + (void)argv; + + FILE *fp = fopen("input", "r"); + if (!fp) + exit(EXIT_FAILURE); + + clock_t tic = clock(); + printf("%d\n", part_one(fp)); + rewind(fp); + printf("%d\n", part_two(fp)); + clock_t toc = clock(); + printf("TIME: %f seconds\n", (double)(toc - tic) / CLOCKS_PER_SEC); + + fclose(fp); + return 0; +} diff --git a/2015/05/Makefile b/2015/05/Makefile new file mode 100644 index 0000000..f757e4a --- /dev/null +++ b/2015/05/Makefile @@ -0,0 +1,19 @@ +DEBUG = -Wno-error -Og -g -s -fsanitize=undefined -fsanitize=address -fstack-protector-all +CFLAGS = -Wall -Wextra -Werror -Wshadow -Wpointer-arith -Wwrite-strings -Wredundant-decls -Wnested-externs -Wformat=2 -Wmissing-declarations -Wstrict-prototypes -Wmissing-prototypes -Wcast-qual -Wswitch-default -Wswitch-enum -Wunreachable-code -Wundef -Wold-style-definition -Wvla -pedantic-errors -Ofast + +# Not the best makefile but idc + +debug: + @gcc $(CFLAGS) $(DEBUG) solve.c -o solve.o + +build: + @gcc $(CFLAGS) solve.c -o solve.o + +clean: + @rm -f *.o + +run: debug + @./solve.o + +time: build + @./solve.o diff --git a/2015/05/input b/2015/05/input new file mode 100644 index 0000000..5642100 --- /dev/null +++ b/2015/05/input @@ -0,0 +1,1000 @@ +rthkunfaakmwmush +qxlnvjguikqcyfzt +sleaoasjspnjctqt +lactpmehuhmzwfjl +bvggvrdgjcspkkyj +nwaceixfiasuzyoz +hsapdhrxlqoiumqw +lsitcmhlehasgejo +hksifrqlsiqkzyex +dfwuxtexmnvjyxqc +iawwfwylyrcbxwak +mamtkmvvaeeifnve +qiqtuihvsaeebjkd +skerkykytazvbupg +kgnxaylpgbdzedoo +plzkdktirhmumcuf +pexcckdvsrahvbop +jpocepxixeqjpigq +vnsvxizubavwrhtc +lqveclebkwnajppk +ikbzllevuwxscogb +xvfmkozbxzfuezjt +ukeazxczeejwoxli +tvtnlwcmhuezwney +hoamfvwwcarfuqro +wkvnmvqllphnsbnf +kiggbamoppmfhmlf +ughbudqakuskbiik +avccmveveqwhnjdx +llhqxueawluwmygt +mgkgxnkunzbvakiz +fwjbwmfxhkzmwtsq +kzmtudrtznhutukg +gtvnosbfetqiftmf +aoifrnnzufvhcwuy +cldmefgeuwlbxpof +xdqfinwotmffynqz +pajfvqhtlbhmyxai +jkacnevnrxpgxqal +esxqayxzvortsqgz +glfoarwvkzgybqlz +xdjcnevwhdfsnmma +jyjktscromovdchb +pvguwmhdvfxvapmz +iheglsjvxmkzgdbu +lwjioxdbyhqnwekv +zcoguugygkwizryj +ogvnripxxfeqpxdh +hkvajhsbfnzsygbm +cnjqeykecopwabpq +wojjtbcjinoiuhsj +kpwpvgxbyzczdzjq +wrvhylisemlewgzk +uiezkmnhilfzahtm +mucteynnuxpxzmvt +zaiwbgxefusfhmst +apptbogpxivjwink +qryboarjtwjhjgjb +irehxupgyseaahzd +fobstqxguyubggoh +ysriumfghtxtfxwe +auchdmasvfeliptw +mztuhefcrnknyrdl +tyjmkhihbwabjtaa +yquzkdtgsljkaebw +almvdvofjtkyzbmd +emqftiuqqpdwwbrv +hrrhmqfpepvbawvw +atrkgykycvgxbpyb +dhthetnealksbdan +zzqafhgicubptiyo +qdtaieaziwhbttnw +kyskgapdgqrtrefw +edwzlpqztpydmdlr +awszjnlmvlyqsuvl +kcrtmtshtsgixvcp +jtaskgkijivbbkri +mmggfwapsetemiuj +itagrrnjbnmhgppd +uqmbezechbrpbnqq +nnyimvtascflpzsa +knqeimypkdttyudj +vgoiyvtvegwyxjjd +qubzdxsbecktzrho +zehojtvktsbbxijb +xepmjrekwcgoxyoh +bnptxnocbpbqbyeq +sfvynsywscbnymos +dsltfbpcmffbluba +kncrlzlmkikylppa +siwudrvmildgaozv +jhhefbvbvneqzvtc +lqjgztxitbuccqbp +himmwlbhjqednltt +vwognchyertnnfil +eejakhapkbodrntf +qxuijkkhhlskgrba +aankpfxxicfpllog +vuxykvljyqexfhrn +epgygflbxlbwybzq +zuxmwvetmvcszayc +xttwhfqmemgtjnkf +hftwldmivyfunfvl +bejlyxfamzliilrj +zkehazcxyyvtrxti +dsgafehmcfpycvgz +igremmqdojqdvwmb +swnjzvmhcslvkmiw +fchzbfbmtqtxmaef +xwjmyyrlznxrcytq +brwcwzpcvbwdrthl +fvrlridacsiojdmb +mhsturxdlmtxozvy +usxvqyrwywdyvjvz +gwazuslvmarfpnzm +rgkbudaqsnolbcqo +dpxvlbtavdhdedkj +nnqmjzejhodyfgyd +ozoazxkfhujgtzvy +psdgvhzdiwnuaxpl +tznkilxpogbzgijz +wnpytcseirtborhh +lhauurlfsmagfges +oqfbzixnlywkzwwy +yoehapoyjpakziom +vtjftdcsfdzbmtrn +zcshfnodiwixcwqj +wapbxpaxgjvtntkm +qfyypkyvblrtaenh +bsxhbxkovgukhcza +kitdmvpiwzdonoyy +slkbhxmehzavbdsf +dovzjouqkzkcmbkl +qpbigdcqkfnfkxvq +eaiaquhnesvtcdsv +mhbezlhqojdsuryj +dqprkkzxlghkoccx +xqepmorryeivhrhm +frwmrjpezwmjflvf +gjpfgwghodfslwlf +fzyvajisdjbhfthq +pvzxkxdscdbilrdb +mtaxmqcnagmplvnm +rlyafujuuydrqwnc +gvqvrcxwyohufehq +lmrkircgfrfusmfd +ovlpnkxcpimyaspb +xhyjremmqhdqywju +pxfczlhpzbypfarm +utjhprzhtggausyp +utzkkzlnyskjtlqh +cecbcnxpazvkedic +xwvoaggihrbhmijq +krredhmtwlfmyagw +lwfhxgbknhwudkzw +vyczyvuxzmhxmdmn +swcoaosyieqekwxx +waohmlfdftjphpqw +gaclbbfqtiqasijg +ybcyaxhluxmiiagp +xgtxadsytgaznndw +wzqhtjqpaihyxksm +fdwltsowtcsmsyhm +rpoelfbsararhfja +tswgdacgnlhzwcvz +xjgbhdlxllgeigor +ksgthvrewhesuvke +whgooqirdjwsfhgi +toztqrxzavxmjewp +hbkayxxahipxnrtl +lazimkmdnhrtflcu +ndoudnupbotwqgmr +niwuwyhnudxmnnlk +hlmihzlrpnrtwekr +wzkttdudlgbvhqnc +rfyzzgytifkqlxjx +skddrtwxcyvhmjtb +mljspkvjxbuyhari +xwkhozaoancnwaud +nookruxkdffeymdz +oiqfvpxmcplyfgoa +qoxggshmrjlzarex +lsroezewzkrwdchx +nkoonmvdydgzspcl +lygxeqztdqklabov +jempjyzupwboieye +hpdaqkhjiddzybly +cvcizjlnzdjfjlbh +vaaddsbkcgdjhbkj +pjxmtxoyrkmpnenf +ujqdvyqnkbusxlps +miyvzkzqploqaceb +gapcsbkulicvlnmo +xqpcyriqhjhaeqlj +ipumdjwlldzqhmgh +swdstecnzttmehxe +ucmqordmzgioclle +aywgqhmqlrzcxmqx +ptkgyitqanvjocjn +wcesxtmzbzqedgfl +rnetcouciqdesloe +chpnkwfdjikqxwms +onpyrjowcuzdtzfg +tydnqwaqwkskcycz +dhamguhmkjzzeduy +oecllwyrlvsyeeuf +gsukajpoewxhqzft +sgdnffdixtxidkih +pqqzjxzydcvwwkmw +wnjltltufkgnrtgm +hylaicyfrqwolnaq +ovfnugjjwyfjunkm +xknyzsebmqodvhcl +uwfmrjzjvvzoaraw +zaldjvlcnqbessds +zphvjuctrsksouvz +ceqbneqjwyshgyge +wmelhaoylbyxcson +nghuescieaujhgkj +dhjmflwwnskrdpph +exvanqpoofjgiubf +aidkmnongrzjhsvn +mdbtkyjzpthewycc +izctbwnzorqwcqwz +hrvludvulaopcbrv +mrsjyjmjmbxyqbnz +sjdqrffsybmijezd +geozfiuqmentvlci +duzieldieeomrmcg +ehkbsecgugsulotm +cymnfvxkxeatztuq +bacrjsgrnbtmtmdl +kbarcowlijtzvhfb +uwietqeuupewbjav +ypenynjeuhpshdxw +fwwqvpgzquczqgso +wjegagwkzhmxqmdi +vocvrudgxdljwhcz +nnytqwspstuwiqep +axapfrlcanzgkpjs +lklrjiszochmmepj +gxadfpwiovjzsnpi +qidsjxzgwoqdrfie +wgszciclvsdxxoej +kwewlmzxruoojlaq +ywhahockhioribnz +ucbqdveieawzucef +mdyyzmfoaxmzddfv +hsxnabxyqfzceijv +vivruyvbrtaqeebr +jxfeweptjtgvmcjc +mmypqxmpurhculwd +mpiaphksvctnryli +xqzqnuxmuzylkkun +fndmtefjxxcygtji +dnorqlldvzqprird +nutokyajmjpwjaqu +vlupfperqyqkjcaj +dgihjeokrphkpdnk +nvbdyrlheqzixuku +mhrkntnxvsmvrpka +kvhkyanlhhymwljf +fhipumtegqfgeqqw +vpfjgveycdefuabu +kzincljffncylcsf +tsezxymwmjtyegqw +wxhcdrqedkdcwxli +ueihvxviirnooomi +kfelyctfvwyovlyh +horzapuapgtvzizz +iiqkdpmfvhwwzmtj +rsaclclupiicstff +quwkkhrafypkaoum +gyrgkgmwqfkeudfe +noydhbqacwptyfmy +efwwuipzgtkwffhf +suyojcitomdxsduh +lbcxnsykojkufkml +zpglsvoutvzkgdep +usgrufyvgsbsmbpr +katrrwuhwvunjqor +btngwrpcxoyfbgbc +bxjscjdiowjrkpns +nwxvnfrnlkgqxvhf +ikhyqkvljucgdlag +xibnxsjopmxvflkl +mzplumcfivqcjqnz +jqflcxoxzlbwlxry +fcscvmfepdxrshxe +wlpffwunffklzbuc +emvrlqajjgwzfmle +rhaheurtzrfoqkyq +ifuuhpxmadaysfsx +ncyfvleyzqntpcoo +zeogmyaqccmtvokd +jqppbzebppdnpurn +xixarswxsiwjzgni +ezruwzajsoombphs +hmiqfeizyprielxf +jnaoxljnftymsfey +extgzrxzovlsixnf +yhyfmovvlrwoezsv +ffnybaolppuzpjym +pqowimdiusccaagn +jgceiosiihpjsmnu +hkoexeaopebktngx +njhzuvsygymejqav +yjkgcclgtvushcfk +gmbjxhnkkxlihups +pdlwysadiebsidjz +omrwmgzulfoaqros +ofvvgdezwvcffdcy +otytpuklhxcpxhgd +eyfaosxdauumvlux +mvdthjfstrlqlyuo +mdgdchgnlxaxspdm +bakjezmhbwqxzevd +msakswaphdwaodhg +vjcqscgdbnsxdllh +jjywaovewbuzreoj +nqvplhwacylifvwk +lpwmpixbxysmsign +flcvbpxrchcpbgcb +qjpkeuenenwawlok +bnqkflfmdmntctya +fzsgzpoqixvpsneq +icwfdisutoilejld +relchofohnkwbumi +aljalgdaqwhzhfwr +cahkvnwnbwhodpqs +dnrzeunxiattlvdm +nsmkhlrpwlunppjs +mqqsexlwfqnogwub +tfavelkqrtndpait +ooguafrnmprfxcnz +ntynkiordzxtwrqa +rkkyzlxekqqlkvym +ofxcivdnwcmgfnme +ywotqwbrqxlrnobh +nrbbiypwhrqihvev +flqsjixxtydheufs +lcfrfzypstrqctja +hyzbuzawuzjrynny +exfbywcnstebnvmq +vydzwnbmcihvqrnj +qmwqaaylinzrdmiw +lpxpztpvfggspeun +lhxmqqbracsuyrfm +zgkwsrabaseidbrw +yjlmbhbqsqgszsun +mqfzqtbxtuteabtd +izomzdmcqmfrevwd +iqijrlqurdwrkoln +fxhqzpgoxxjkkhql +oulwontmgrjeopnk +edaigfydjexvzzvj +vjhybiklxpxjqpwc +ypxfbfnpbmqmwtte +xzvcsgasztrxdzud +rpulqmobptfarboo +palacmdijxzzykrf +jmllwukplufohiby +dnswayomusiekfmy +sxbrjqtqgzzwhcfo +lylvndsgbnbqiejm +jaxxhoulxnxnaenr +nblissutfazbcpwn +zmlsjszzldvbiacr +kewojtlchfkclqwk +eqvfjasddggvfame +yibzqlvxtraxpdon +dgnbxsbmdrtyvaac +uoxrcxfimhgtxqhy +xfdxalrwcwudlviq +xmtbdklqptoswpwl +zezyopzdztdjerfl +xuzluhjsqvhytgbc +qdjtmeckispmgzki +phakupesplzmmmvc +gpuoqfffumzszybn +bhywxqkrrlwuebbw +ibvwgoyvelzenkzl +ncohvvbmiekbaksa +fzuvqzvxvdbeirrp +lshtzniokucwojjd +punrduvlnrulkium +gnfpikidnfobrrme +vxkvweekmnvkzgyl +rhydssudkcjlqgxn +cjtqvlaahohcgumo +jwzmfyinsfwecgcb +blpeseqhlzfilpuf +jvtpjkyokzcvagon +qjomincbcobjczpe +ugsyzkzgdhxtmsfz +hleaqgwzqjwajcra +coumfghptpnxvvov +hqpnbupnzwpdvgqd +cpouyodqxgviasem +lljvxeyozckifhfd +huqtnvutdyfgwtwa +yenlveuynmlmmymu +ojdyufkomxiwjmbf +spjzgvcwvzgffjkk +vxykmjhyvmhyssbp +tazdeqggfcjfvwwn +uumwcngwcytvpufx +avovuzkrevloneop +owczrtbnrvjfemkt +hzpugcanaxyvaokj +iishlodnxvjtgzyn +qosdonclrnxirham +eonqlnwevahydddg +ryqmnuikftlxuoqy +whqepbcwabzbthha +vekisvnwhgpyemxr +lrwxzoamnvpnlhap +ywepvqthnorfswjv +evqwvsoazmwyypjy +bgwoojddubppmjxf +jypkfrthzgtyeddi +tynabbhfjzkrqsju +adxstbfqheuqbcuk +gqwqiocdyqoiblrx +ybuddlyuskdlegxv +luwynbsmpgyeqsbr +ltyqgqoyljibqndo +jaedpajzphfybajh +epglnrxofptsqvmy +zjdpxkngfkstxbxh +ekegphcwanoickfu +cqvhuucvejqirvfs +uqudnnqumsqcgefo +qnzunermlnpcfflo +ovyxaniqaawzfuxx +djekxcezjowdhopq +bwtwbmdehrhpjnlk +nilsnlacerweikfa +hyrigsrmsrzcyaus +gvmdmgddduylmxic +ewzovdblhmjgjwsk +ojjfsknlonzguzlq +yjgfruvpjvlvrvvq +cyoryodwyhzwprbv +crsjclrurcquqgut +sjhfhobwtojxcmem +ibxfjudilmdeksea +uqbhdbjoeupyhbcz +uqbxigzxuxgmjgnw +jashafmtzrhswirg +dexiolovaucyooka +czjbwwnlwcoqnoiu +ojigosazigfhttjc +zfiqtgrqbmftknzn +dlzbmvmolssbqlzl +sgmchcurrutdtsmw +scdwjqsdohcdrwry +cgtdvecqwplpprxn +iiplenflfczaktwi +wmgnwfxfcjhyeiqg +giihshowtcatecvl +nqhzfincclumvkaz +kxstpzgdfvepionc +agbhxcijxjxerxyi +hmgfqevgdyvisyvs +tthakmvpowpvhtao +ottalcghygpaafbo +aplvozayycremgqg +dbjxlnaouxqtdpfz +peeyallzjsdvpalc +ndtdjyboixuyhfox +llabnbcobexfoldn +cweuvfnfyumbjvxr +ewkhhepaosalnvkk +pivyiwsiqpwhagyx +auzsnwdcerfttawt +grbfrekupciuzkrt +byfwzadtzrbndluf +lluypxjeljzquptk +pskwsnhqanemtfou +sxvrtqqjdjkfhhrm +ulsmqgmshvijyeqh +qigofesfhekoftkf +zhatniakqtqcxyqa +uuczvylgnxkenqee +mlitvtuxknihmisc +srrtrxdvcokpyfmz +osispuucklxcfkeb +vqhazlaulmnpipql +umkiueljberqhdig +knvpbkbvgoqzwprp +nbsocqikhuvsbloj +wjnpepjkzkednqbm +agbhmytsofuyqcor +gvogzhkkpxyfecko +ardafguxifeipxcn +yiajcskbgykyzzkw +sejunbydztyibnpq +dqrgfggwcnxeiygy +xnqqwilzfbhcweel +jjtifhlvmyfxajqi +gwszrpgpmbpiwhek +kydzftzgcidiohfd +efprvslgkhboujic +kecjdfwqimkzuynx +rildnxnexlvrvxts +dlnhjbqjrzpfgjlk +qluoxmzyhkbyvhub +crydevvrjfmsypbi +dosaftwumofnjvix +pwsqxrfwigeffvef +nzyfmnpwqyygjvfx +iccbckrkxlwjsjat +bmputypderxzrwab +bhuakynbwnlreixb +qmrzfyqjiwaawvvk +juvtixbkwyludftn +zapmjxmuvhuqlfol +paiwrqjhpjavuivm +tsepfbiqhhkbyriz +jpprewufiogxoygk +mmapyxbsugcsngef +pduhmgnepnpsshnh +aetndoqjvqyjrwut +fnfvlorhwpkkemhz +gedfidpwvoeazztl +beclvhospgtowaue +wsclsvthxustmczm +tjbxhnpniuikijhe +rhetyhvfcemponeg +mavonujurprbeexi +argbrpomztrdyasa +bzvtffbtygjxmkvh +maqyqkhsqgzfzvve +seeirbiynilkhfcr +wxmanwnozfrlxhwr +dieulypsobhuvswb +nxevassztkpnvxtb +jclxuynjsrezvlcy +xlolzyvgmwjsbmyf +tguzoeybelluxwxc +fkchoysvdoaasykz +cyynwbfcqpqapldf +rhifmzpddjykktuy +ndvufsyusbxcsotm +txutnzvdsorrixgg +qjoczhukbliojneu +ufhwujotncovjjsz +kclsgsdwcrxsycbr +yscwmlrdaueniiic +nxhivrovpkgsmugb +fdxqfyvwwvgeuqkv +femtamfylysohmpr +amsyzslvyxsoribh +nhmqxncwsonhgbcz +uomqsvcbpthlmcue +kxtfapcqrnjkkslj +xtieihonlfubeync +adpcjqxgydulchgj +cjynnzsmmujsxxpd +neeapmzweidordog +szoivgqyqwnyjsnk +uwgrtzaqezgphdcu +ptpgttqxocjwxohi +fhltebsizfwzpgpf +emmsazsidspkhgnh +dxcprkbcjeqxqzgn +tpxzqwxbzwigdtlt +afsmksnmzustfqyt +xyehnftstacyfpit +vcrfqumhjcmnurlw +rrznpjzcjgnugoch +gbxnzkwsjmepvgzk +jwobshgwerborffm +zmuvfkhohoznmifs +buyuwgynbtujtura +bevncenmpxfyzwtf +hqqtcrhzfsrcutjh +kbpzshllpiowepgc +alspewedcukgtvso +xvsvzzdcgjuvutrw +pmwulqraatlbuski +abuzsiinbueowpqn +oedruzahyfuchijk +avhcuhqqjuqkesoq +azqgplkzsawkvnhb +rjyoydogkzohhcvx +aezxwucqvqxuqotb +kxobnsjvzvenyhbu +nnjoiilshoavzwly +aijttlxjrqwaewgk +cvsaujkqfoixarsw +zngtoacpxcsplgal +qhkxliqtokvepcdv +aixihrtdmxkfvcqw +owbgdgdymxhhnoum +tajsagmruwzuakkd +ckrfduwmsodeuebj +alfdhuijuwyufnne +xpchlkijwuftgmnm +rwcrvgphistiihlg +xdaksnorrnkihreq +akeschycpnyyuiug +rgputhzsvngfuovz +lerknhznuxzdhvre +mqiqmyladulbkzve +csnmupielbbpyops +kwgrwgmhfzjbwxxz +npwtvbslvlxvtjsd +zxleuskblzjfmxgf +hexvporkmherrtrn +rhtdhcagicfndmbm +qhnzyuswqwoobuzz +dpvanjuofrbueoza +kjcqujmnhkjdmrrf +gholddsspmxtpybg +jihlvyqdyzkshfsi +zuviqmuqqfmtneur +kzexjowatvkohrtx +wgijnfhibsiruvnl +zevkrkmhsxmicijb +khxrcteqourjvoxa +ylpxlkcnenbxxtta +zrfsvctbojjkpvtw +nlzbudxibnmcrxbt +cqnscphbicqmyrex +ywvdohheukipshcw +riwatbvjqstubssf +idlztqqaxzjiyllu +sdpdgzemlqtizgxn +rjtbovqlgcgojyjx +fnfrfwujmjwdrbdr +osnppzzmrpxmdhtj +ljhwngclvydkwyoe +chwqkrkzrvjwarat +jmydkwpibkvmqlgs +zvhfmbxnlxtujpcz +jsnhsphowlqupqwj +fzhkkbpasthopdev +jerntjdsspdstyhf +gctwmaywbyrzwdxz +xemeaiuzlctijykr +xulrqevtbhplmgxc +yfejfizzsycecqpu +gboxrvvxyzcowtzm +lpvhcxtchwvpgaxp +wdiwucbdyxwnjdqf +qgwoqazzjlvnjrwj +prtlnkakjfqcjngn +fagvxsvjpuvqxniz +xacmxveueaakfbsm +ginvtonnfbnugkpz +qpvggsppewfzvwin +reoqnlzruyyfraxa +kolwtqhifjbbuzor +vrkcywvdhdprztww +ngdvyfmvjqhbzbxt +rooxeoilqzqjunmp +efxmdprtogtxgyqs +qrhjuqndgurcmwgu +ouitjprueefafzpl +kirdwcksqrbwbchp +fpumsmogojuywezo +lgjrgykywugzjees +xigioqcpjabpbdas +ewkhuprpqzikmeop +fgrgxsqeducigxvr +bclkursnqkzmjihl +jozidniwvnqhvsbc +oghcilcyozrmmpta +xbgmaungzcpasapi +iqowypfiayzbcvhv +opdehgwdgkocrgkf +zfzvdjeinlegcjba +vhakxvlcayuzukap +xyradgyiebpevnwe +eamhtflgedwyshkn +igteqdgchjeulfth +kwsfkigxzpbgdxod +vapnpsbdboiewpzp +wbuqhjsngxpqshen +vxxilouxuytitwgm +cpnwlkwnkeanqnet +wdmbtqvvlowftvgb +wjtmcecpyqzwpbqg +jnxmoxdhvsphcdeg +wabxfxpotoywwodn +mwbsoxzlqpqobvvh +coktshbyzjkxnwlt +rzhnggpslwzvyqrp +dgzuqbzarbutlkfx +wunajaiiwgijfvjh +uotdbcgmsvbsfqlb +kxdtlgmqbccjqldb +ngmjzjwvwbegehfr +cvpsabqfpyygwncs +wqluvqlhdhskgmzj +rbveperybfntcfxs +fbmoypqdyyvqyknz +zxpgzwnvmuvkbgov +yexcyzhyrpluxfbj +ltqaihhstpzgyiou +munhsdsfkjebdicd +plecvjctydfbanep +kjrxnnlqrpcieuwx +zbcdtcqakhobuscf +kgovoohchranhmsh +llxufffkyvuxcmfx +tgaswqyzqopfvxtw +kojcqjkdpzvbtjtv +xggdlkmkrsygzcfk +vvitpsnjtdqwyzhh +gcqjuwytlhxsecci +vbsghygcsokphnrg +vejqximdopiztjjm +hudqtwmwkviiuslp +vwswfvpcwwpxlyry +gxmfiehdxptweweq +qjmekjdcedfasopf +pqyxdxtryfnihphf +felnavctjjojdlgp +hbimufguekgdxdac +dhxhtnqgfczywxlr +pssottpdjxkejjrh +edieanguabapxyig +sciinanyqblrbzbb +irxpsorkpcpahiqi +qsxecaykkmtfisei +ivfwlvxlbnrzixff +hqxzzfulfxpmivcw +vvbpaepmhmvqykdg +cetgicjasozykgje +wuetifzdarhwmhji +gaozwhpoickokgby +eldnodziomvdfbuv +favpaqktqaqgixtv +twbcobsayaecyxvu +lzyzjihydpfjgqev +wnurwckqgufskuoh +fxogtycnnmcbgvqz +aetositiahrhzidz +dyklsmlyvgcmtswr +ykaxtdkjqevtttbx +kfmnceyxyhiczzjm +nnizopcndipffpko +yjmznhzyfinpmvkb +sljegcvvbnjhhwdd +zmkeadxlwhfahpwg +rwvcogvegcohcrmx +aguqwrfymwbpscau +vlusytjagzvsnbwe +smvzhburcgvqtklh +rfuprvjkhazrcxpv +megqlnoqmymcrclc +gvldhkewtmlwqvqv +awynhvtyziemnjoa +voprnvtnzspfvpeh +dhlguqwmunbbekih +goayirdhnjrfuiqi +eoghydfykxdslohz +chpippjykogxpbxq +hqbycjweqczwjwgf +pvefsrvwumrlvhmt +eghwdovaynmctktk +crwkxoucibumzawc +bzbtahvhkdigvvtj +bnbptgihhfubxhho +ddqmbwyfmfnjjaro +gvtswqyzazihctif +vmqctjpgadxztqqb +dgnndowtpeooaqqf +sxdvctfdtalufxty +ylgeexosibsmmckw +sxplpyskbpqnojvw +coarhxtsvrontyeg +fyoaurggjupvzvlv +jlyrkqsiwuggvjem +uwbsjoxonreuucyi +gihuqvwxovbgokes +dxzaaxupbcgnxcwf +gidrgmvyrlqqslve +csflmlvqmonoywpx +jkxkpixlythlacnk +ejkarcdkdslldugv +dbzmsusevohhjkmr +cbrqzualjpdtworc +kpgidqlmcbpfmmwu +zwghjuofexfowqam +ncdlxmcrsmsocetz +kfprzqacefifjkbd +swwzivrxulkhvldc +wgqejhigbjwunscp +rsstnwcyybfauqxu +qhngfxyhdqopyfgk +zrndpyyejsmqsiaj +xxknxwpvafxiwwjc +mmaahwgoiwbxloem +tabacndyodmpuovp +yriwomauudscvdce +duvyscvfidmtcugl +mgipxnqlfpjdilge +imeeqcdetjuhfjnw +dvkutrdofpulqkyh +jefvtlktxegpmbya +iyzudqgpvlzjfydh +giohapxnpaqayryd +qheqdprmnqlpztls +rdxhijmzegxkotoq +hdnmaspumdwnrcdz +wafpbgehbuzdgsnc +tbtrfztsferdmhsy +vusndcyjngtkrtmk +ilqblestzxebcifh +urfgjbjgzlrfsdlv +aptcdvpsqwleqttn +bigczjvzokvfofiw +zjnjeufonyqgkbpx +trcdebioegfqrrdi +jrdvdriujlmbqewt +jqrcmuxpwurdhaue +yjlermsgruublkly +zwarvgszuqeesuwq +xthhhqzwvqiyctvs +mzwwaxnbdxhajyyv +nclsozlqrjvqifyi +gcnyqmhezcqvksqw +deuakiskeuwdfxwp +tclkbhqqcydlgrrl +qbpndlfjayowkcrx +apjhkutpoiegnxfx +oaupiimsplsvcsie +sdmxrufyhztxzgmt +ukfoinnlbqrgzdeh +azosvwtcipqzckns +mydyeqsimocdikzn +itfmfjrclmglcrkc +swknpgysfscdrnop +shyyuvvldmqheuiv +tljrjohwhhekyhle +dayinwzuvzimvzjw +qgylixuuervyylur +klqqaiemurawmaaz +hdmzgtxxjabplxvf +xiivzelzdjjtkhnj +ktgplkzblgxwrnvo +gvbpyofzodnknytd +lqhlmnmhakqeffqw +ltzdbngrcxwuxecy +obxnfjeebvovjcjz +zexpwallpocrxpvp +tjpkkmcqbbkxaiak +qiedfixxgvciblih +qcxkhghosuslbyih +gnsfidwhzaxjufgm +xrghwgvyjakkzidw +tftftwedtecglavz +wquqczzkzqrlfngr +twibtkijpvzbsfro +bmplypdsvzuhrjxp +zanrfmestvqpwbuh +zonrhfqowyimcukm +kpvajjfmqpbhrjma +kujzluicngigjbtp +iusguantsrwxdjal +kwxeuylcnszswahw +visdhnkobxnemldu +rogeadmmaicwtabl +pxqycifbgevqudvs +osaiozyvlyddylqr +vffjxrolrpuxcatx +jbmsetccdrywssjd +qgxyhjfpbfifmvgc +npejgalglldxjdhs +mbbtqgmttastrlck +whapaqwdtpkropek +dulbdboxazfyjgkg +xaymnudlozbykgow +lebvqmxeaymkkfoy +bmicnfuubkregouj +dieatyxxxlvhneoj +yglaapcsnsbuvrva +bbpjaslqpzqcwkpk +xehuznbayagrbhnd +ikqmeovaurmqfuvr +ylyokwuzxltvxmgv +hqtfinrkllhqtoiz +pjmhtigznoaejifx +fqdbmowkjtmvvrmx +uvqtqfoulvzozfxv +rpajajukuxtchrjd +sznucejifktvxdre +ufvibsmoushmjbne +xirdqoshngthfvax +iafpkddchsgdqmzl +vmualmlduipvykzh +fnmuahmblwyceejb +ilsaapnswfoymiov +lenvylifraahaclv +cukqxlipuyxedqfh +zgwecslpniqvtvuz +cdcdfpsxuyrhsmag +dszjinhantnxgqra +ioimwotsgnjeacgt +dqcymnvjystbynhp +yibaudyfefbfgunx +cabslcvunjavqkbf +goymzvmgkvlsmugf +zxteiitpthzskjjx +agnxcnaqhjhlurzs +cvmgyxhhnykuxbmb +cgqmjexydmvgwxpp +sygjajofieojiuna +clpvxbrbjvqfbzvu +cbntswqynsdqnhyv +bztpbtwbefiotkfa +pnxccbgajvhyeybu +asyzrvgzumtuissa +facjyblvcqqginxa +rvwnucnbsvberxuv +ghrbeykzrxclasie +ekujtselepgjtaql +krtrzsmduhsifyiw +ticjswvsnyrwhpnt +clmjhsftkfjzwyke +lbxlcixxcztddlam +xhfeekmxgbloguri +azxqwlucwhahtvep +kitdjrwmockhksow +keznwwcusgbtvfrs +ljvzxoywcofgwajj +vebjnhnkcfzbhrcw +eqfcxkavstxcuels +ldattkyawjrvcido +bsqqeilshcwtqyil +foqqsxahfiozcqrw +liswfmuhzfbyzjhf +sulbdcyzmolapfbs +zuggzkelwxjpsgxb +betioxrgtnhpivcw +xmtbixstdipibhgs +ttvurgqmulryyaji +viobnljznzppfmxw +qlzabfopydtxrlet +tusvydegfxhaxolk +thoufvvfjferxhwp +cfyyzppfarjiilbs +jwmhxtgafkkgseqs +pqwuuaxbeklodwpt +vndyveahdiwgkjyx +ssrjgasfhdouwyoh +thbavfcisgvvyekf +yjdvxmubvqadgypa +tlbmcxaelkouhsvu +bonohfnlboxiezzr +rktlxcbkhewyvcjl +rsmoutcbcssodvsc +qszdratuxcrhsvoh +eypyfahpuzqwzwhi +yhkrleqmqlmwdnio +vpnvxusvmngsobmq +hkzyhopvxrsimzys +dblriiwnrvnhxykl +xkriqxkrprjwpncs +rcymltrbszhyhqti +mzbvneplsnpiztzn +vkqtnptgbqefvfoc +nwdtfiaozkcjtlax +crximadpvdaccrsm +lrbajafxwwnxvbei +rbexzesrytpwwmjf +stxwjarildpnzfpg +btamaihdivrhhrrv +acqbucebpaulpotl +dkjhzghxxtxgdpvm +rsbzwsnvlpqzyjir +mizypbwvpgqoiams +nvrslorjpqaasudn +wvexcpzmconqkbvk +rfwfumhjwzrvdzam +eaghdaqorkhdsmth +gtuntmpqaivosewh +nzlsmdgjrigghrmy +dhuvxwobpzbuwjgk +kkcuvbezftvkhebf +aeediumxyljbuyqu +rfkpqeekjezejtjc +wkzasuyckmgwddwy +eixpkpdhsjmynxhi +elrlnndorggmmhmx +ayxwhkxahljoxggy +mtzvvwmwexkberaw +evpktriyydxvdhpx +otznecuqsfagruls +vrdykpyebzyblnut +cnriedolerlhbqjy +uajaprnrrkvggqgx +xdlxuguloojvskjq +mfifrjamczjncuym +otmgvsykuuxrluky +oiuroieurpyejuvm diff --git a/2015/05/solve.c b/2015/05/solve.c new file mode 100644 index 0000000..3ae59f9 --- /dev/null +++ b/2015/05/solve.c @@ -0,0 +1,105 @@ +#include <stdio.h> +#include <stdlib.h> +#include <time.h> + +#define FORLINE \ + char *line = NULL; \ + size_t len = 0; \ + while (getline(&line, &len, fp) != EOF) +#define FREELINE \ + if (line) \ + free(line) + +#define FORCH \ + char ch = 0; \ + while ((ch = fgetc(fp)) != EOF) + +#define FORP for (const char *p = line; *p && p; p++) + +#define WHOLE \ + fseek(fp, 0, SEEK_END); \ + long fsize = ftell(fp); \ + fseek(fp, 0, SEEK_SET); \ + char *data = malloc(fsize + 1); \ + fread(data, 1, fsize, fp); \ + data[fsize] = 0; +/* data[fsize--] = 0 */ + +static int part_one(FILE *fp) +{ + int res = 0; + + FORLINE + { + int vowels = 0, dub = 0, illegal = 0; + FORP + { + if (*p == 'a' || *p == 'e' || *p == 'i' || *p == 'o' || *p == 'u') + vowels++; + + if (p - line > 1 && *p == *(p - 1)) + dub++; + + if (p - line > 1 && + ((*(p - 1) == 'a' && *p == 'b') || (*(p - 1) == 'c' && *p == 'd') || + (*(p - 1) == 'p' && *p == 'q') || (*(p - 1) == 'x' && *p == 'y'))) { + illegal = 1; + break; + } + } + + if (vowels >= 3 && dub >= 1 && !illegal) + res++; + } + FREELINE; + + return res; +} + +static int part_two(FILE *fp) +{ + int res = 0; + + FORLINE + { + char dub[26] = { 0 }; + int betw = 0; + FORP + { + // TODO: Dub + if (p - line > 2 && *p == *(p - 2)) + betw++; + } + + int dub_cnt = 0; + for (int i = 0; i < 26; i++) + if (dub[i] >= 2) + dub_cnt++; + + if (dub_cnt >= 1 && betw) + res++; + } + FREELINE; + + return res; +} + +int main(int argc, char *argv[]) +{ + (void)argc; + (void)argv; + + FILE *fp = fopen("input", "r"); + if (!fp) + exit(EXIT_FAILURE); + + clock_t tic = clock(); + printf("%d\n", part_one(fp)); + rewind(fp); + printf("%d\n", part_two(fp)); + clock_t toc = clock(); + printf("TIME: %f seconds\n", (double)(toc - tic) / CLOCKS_PER_SEC); + + fclose(fp); + return 0; +} diff --git a/template/c/Makefile b/template/c/Makefile new file mode 100644 index 0000000..4a881b7 --- /dev/null +++ b/template/c/Makefile @@ -0,0 +1,19 @@ +DEBUG = -Wno-error -Og -g -s -fsanitize=undefined -fsanitize=address -fstack-protector-all +CFLAGS = -Wall -Wextra -Werror -Wshadow -Wpointer-arith -Wwrite-strings -Wredundant-decls -Wnested-externs -Wformat=2 -Wmissing-declarations -Wstrict-prototypes -Wmissing-prototypes -Wcast-qual -Wswitch-default -Wswitch-enum -Wunreachable-code -Wundef -Wold-style-definition -Wvla -pedantic-errors -Ofast + +# Not the best makefile but idc + +debug: + @gcc $(CFLAGS) $(DEBUG) solve.c -o solve.o -L/usr/lib -lcrypto + +build: + @gcc $(CFLAGS) solve.c -o solve.o -L/usr/lib -lcrypto + +clean: + @rm -f *.o + +run: debug + @./solve.o + +time: build + @./solve.o diff --git a/template/c/input b/template/c/input new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/template/c/input diff --git a/template/c/solve.c b/template/c/solve.c new file mode 100644 index 0000000..c71182e --- /dev/null +++ b/template/c/solve.c @@ -0,0 +1,58 @@ +#include <stdio.h> +#include <stdlib.h> +#include <time.h> + +#define FORLINE \ + char *line = NULL; \ + size_t len = 0; \ + while (getline(&line, &len, fp) != EOF) +#define FREELINE \ + if (line) \ + free(line) + +#define FORCH \ + char ch = 0; \ + while ((ch = fgetc(fp)) != EOF) + +#define WHOLE \ + fseek(fp, 0, SEEK_END); \ + long fsize = ftell(fp); \ + fseek(fp, 0, SEEK_SET); \ + char *data = malloc(fsize + 1); \ + fread(data, 1, fsize, fp); \ + data[fsize] = 0; +/* data[fsize--] = 0 */ + +static int part_one(FILE *fp) +{ + int res = 0; + + return res; +} + +static int part_two(FILE *fp) +{ + int res = 0; + + return res; +} + +int main(int argc, char *argv[]) +{ + (void)argc; + (void)argv; + + FILE *fp = fopen("input", "r"); + if (!fp) + exit(EXIT_FAILURE); + + clock_t tic = clock(); + printf("%d\n", part_one(fp)); + rewind(fp); + printf("%d\n", part_two(fp)); + clock_t toc = clock(); + printf("TIME: %f seconds\n", (double)(toc - tic) / CLOCKS_PER_SEC); + + fclose(fp); + return 0; +} |