Created
October 8, 2022 12:37
-
-
Save umgefahren/fc9a4e98033f04c4d332e46e0ea59369 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdint.h> | |
int main() { | |
FILE * inp_file = fopen("input.txt", "r"); | |
uint64_t a = 0; | |
uint64_t b = 0; | |
uint64_t c = 0; | |
uint64_t slider = 0; | |
uint64_t incremented = 0; | |
for (;;) { | |
uint64_t current_depth; | |
int output = fscanf(inp_file, "%llu\n", ¤t_depth); | |
if (output == EOF) { | |
break; | |
} | |
uint64_t last_sum = a + b + c; | |
a = b; | |
b = c; | |
c = current_depth; | |
uint64_t current_sum = a + b + c; | |
if (current_sum > last_sum && slider >= 3) | |
incremented += 1; | |
slider += 1; | |
} | |
printf("Counter => %llu", incremented); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment