From 6cabce9380878b79e75e7b9bd2869a671db91087 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 22 Dec 2025 23:58:25 +0000 Subject: [PATCH] m --- 2015_day_5/Makefile | 7 +++ 2015_day_5/day_5.c | 138 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+) create mode 100644 2015_day_5/Makefile create mode 100644 2015_day_5/day_5.c diff --git a/2015_day_5/Makefile b/2015_day_5/Makefile new file mode 100644 index 0000000..e7b14f9 --- /dev/null +++ b/2015_day_5/Makefile @@ -0,0 +1,7 @@ +compile: + gcc day_5.c -Werror=switch -o day5 -march=native -Ofast -flto + +run: + ./day5 +run2: + ./day4 2 \ No newline at end of file diff --git a/2015_day_5/day_5.c b/2015_day_5/day_5.c new file mode 100644 index 0000000..5f97caa --- /dev/null +++ b/2015_day_5/day_5.c @@ -0,0 +1,138 @@ +#include +#include +#include +FILE *fptr; + + +struct __attribute__((packed)) { + unsigned int w0 : 1; + unsigned int w1 : 1; + unsigned int w2 : 1; + unsigned int w3 : 1; + unsigned int w4 : 1; + unsigned int f0 : 1; +} bitfield; + + +//RULES: Must match all 3 +//Contains 3 vowels: aeiou only +//At least one letter appears twice in a row +//It does not contain the strings ab, cd, pq, or xy +int main(){ + + fptr = fopen("input", "r"); + if(fptr == NULL) { + printf("Not able to open the file."); + return 1; + } + long long int line_count = 0; + long long int nice_strings_count = 0; + long long int new_nice_strings_count = 0; + long long int naughty_strings_count = 0; + char buffer[266]; + int cnt_1 = 0; + int cnt_2 = 0; + int cnt_3 = 0; + char compare_1[3]; + char compare_2[3]; + while (fgets(buffer, sizeof(buffer), fptr)) { + line_count++; + bitfield.w0 = 0; + bitfield.w1 = 0; + bitfield.w2 = 0; + bitfield.w3 = 0; + bitfield.w4 = 0; + bitfield.f0 = 0; + cnt_1 = 0; + cnt_2 = 0; + cnt_3 = 0; + //loop 1 aeiou + for(int i = 0; i