2
1
Fork 0
aoc2021/01/solution.c

20 lines
339 B
C
Raw Normal View History

2021-12-01 10:10:04 +01:00
#include <stdio.h>
#include <stdint.h>
#include "input.h"
int main(void) {
uint16_t answer = 0;
2021-12-01 10:12:01 +01:00
uint32_t prev = 0;
for (uint16_t *p = input+3; p < (&input)[1]; p++) {
uint32_t new = *(p-2) + *(p-1) + *p;
if (new > prev)
2021-12-01 10:10:04 +01:00
answer++;
2021-12-01 10:12:01 +01:00
prev = new;
2021-12-01 10:10:04 +01:00
}
printf("Answer: %d\n", answer);
}