#include #include #include #define WINDOW_SIZE 3 int main() { FILE *input = fopen("input", "r"); if(input == NULL) { printf("oh noes couldn't open the input file lol\n"); return 1; } char line[255]; int index = 0, count = 0, last_num = INT_MAX; int windows[WINDOW_SIZE][WINDOW_SIZE]; while(fgets(line, sizeof(line), input) != NULL) { int cur_num = atoi(line), cur_index = index % (WINDOW_SIZE); // Put values diagonal into the 3x3 grid, like this // A B C // B C A // C A B for(int i=0; i last_num; last_num = sum; } fclose(input); printf("There were %d measurements larger than the last.\n", count); }