diff --git a/day9/Makefile b/day9/Makefile index d21ba00..6d35555 100644 --- a/day9/Makefile +++ b/day9/Makefile @@ -32,6 +32,10 @@ part1: $(SRC) | input.h $(CC) $(SRC) $(CFLAGS) -o $@ $(LDFLAGS) strip $@ +part2: $(SRC) | input.h + $(CC) $(SRC) -DPART2 $(CFLAGS) -o $@ $(LDFLAGS) + strip $@ + part1-test: $(SRC) | input-test.h $(CC) $(SRC) -DTEST $(CFLAGS) -o $@ $(LDFLAGS) strip $@ diff --git a/day9/day9.c b/day9/day9.c index 0d7c837..56c4eb5 100644 --- a/day9/day9.c +++ b/day9/day9.c @@ -45,9 +45,58 @@ static void calculate_deficits(const u64 pre[static PREAMBLE], map_t * restrict } #ifdef PART2 +static u64 csum(size_t i, size_t j) +{ + register u64 sum=0; + for(;i<=j;i++) + sum += input[i]; + return sum; +} +static void reduce_bound(size_t* restrict i, size_t* restrict j, bool ex_by_high) +{ + register u64 ibound = 0; int iset=0; + register u64 jbound = 0; int jset=0; + + if(*ijbound ? i : j) += (ibound>jbound ? iset : jset); + else + *(iboundjbound ? i : j) += (ibound>jbound ? iset : jset); + else + *(ibound target) { + reduce_bound(&i, &j, true); + } + } + fprintf(stderr, "No set found\n"); + return 1; } #endif