2
1
Fork 0

Day 1: Update C solution for part 2

This commit is contained in:
Mia Herkt 2021-12-01 10:12:01 +01:00
parent 56b390dc29
commit f1779d53d4
Signed by: mia
GPG key ID: 72E154B8622EC191

View file

@ -5,9 +5,14 @@
int main(void) {
uint16_t answer = 0;
for (uint16_t *p = input+1; p < (&input)[1]; p++) {
if (*p > *(p-1))
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);