You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
504 B

#include <input.h>
#include <pairs.h>
struct window {
input_t pre, cur, suc;
};
__attribute__((pure))
inline static input_t sum_window(const struct window* restrict w)
{
return w->pre + w->cur + w->suc;
}
int part2(uint64_t* restrict _res)
{
uint64_t res=0;
for(size_t i=0;i<INPUT_SIZE-2;i++)
{
struct ipair w6;
w6.prev = sum_window((const struct window*)(INPUT+i));
w6.next = sum_window((const struct window*)(INPUT+i+1));
res += (w6.prev < w6.next);
}
*_res = res;
return 0;
}