Day 1: Update C solution for part 2
This commit is contained in:
parent
56b390dc29
commit
f1779d53d4
1 changed files with 7 additions and 2 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue