From: Mart Lubbers Date: Tue, 7 Dec 2021 08:06:14 +0000 (+0100) Subject: improve by only searching halfway X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=4f89ccfe471a725a5d081038c93841b4b3bd36d8;p=advent21.git improve by only searching halfway --- diff --git a/07b.c b/07b.c index 87ba2f0..a711578 100644 --- a/07b.c +++ b/07b.c @@ -24,17 +24,18 @@ int main() ncrabs++; } - int mindist = INT_MAX; - for (int i = minp; i<=maxp; i++) { - int dist = 0; + int lastdist = INT_MAX; + int dist = INT_MAX; + int i = minp; + do { + lastdist = dist; + dist = 0; for (int j = 0; j