2
1
Fork 0
aoc2021/01/solution.c

19 lines
339 B
C

#include <stdio.h>
#include <stdint.h>
#include "input.h"
int main(void) {
uint16_t answer = 0;
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)
answer++;
prev = new;
}
printf("Answer: %d\n", answer);
}