From b07b60ad6feaa27d8d7b66ab0682d8b1de94a7a6 Mon Sep 17 00:00:00 2001 From: Avril Date: Wed, 9 Dec 2020 13:04:36 +0000 Subject: [PATCH] day9: part2 --- day9/day9.c | 54 +++++++++++++++++++++++------------------------------ 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/day9/day9.c b/day9/day9.c index 56c4eb5..e7239bd 100644 --- a/day9/day9.c +++ b/day9/day9.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "map.h" @@ -52,47 +53,38 @@ static u64 csum(size_t i, size_t j) sum += input[i]; return sum; } -static void reduce_bound(size_t* restrict i, size_t* restrict j, bool ex_by_high) +static int _comp_u64(const void* _i, const void* _j) { - register u64 ibound = 0; int iset=0; - register u64 jbound = 0; int jset=0; + const u64* i = _i; + const u64* j = _j; - if(*ijbound ? i : j) += (ibound>jbound ? iset : jset); - else - *(ibound *j ? 1 + : 0; } -static void extend_bound(size_t* restrict i, size_t* restrict j, bool ex_by_high) +inline static u64 ud_sort(size_t i, size_t j) { - register u64 ibound = 0; int iset=0; - register u64 jbound = 0; int jset=0; + u64 slice[input_sz]; + size_t len = j-i; + assert(lenjbound ? i : j) += (ibound>jbound ? iset : jset); - else - *(ibound target) { - reduce_bound(&i, &j, true); + for(register size_t j=i;j target) break; } } fprintf(stderr, "No set found\n");