adventofcode/2021/1/depth.c

29 lines
486 B
C
Raw Normal View History

2022-12-01 21:02:00 +01:00
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
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 count = 0, last_num = INT_MAX;
while(fgets(line, sizeof(line), input) != NULL) {
int cur_num = atoi(line);
count += cur_num > last_num;
last_num = cur_num;
}
fclose(input);
printf("There were %d measurements larger than the last.\n", count);
}