From 94d0033ed89bb5bfb6500051296892fb7cea6c29 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 25 Dec 2023 17:56:34 +0100 Subject: Small cleanup --- 2023/20/20a.c | 4 +--- 2023/20/20b.c | 13 +++++-------- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to '2023/20') diff --git a/2023/20/20a.c b/2023/20/20a.c index 99b6874..1fda99e 100644 --- a/2023/20/20a.c +++ b/2023/20/20a.c @@ -1,7 +1,6 @@ #include #include #include -#include #include #define N 100 @@ -95,7 +94,6 @@ int main() { for (int i = 0; i < 1000; i++) pushbutton(); - printf("%" PRId64 " (%" PRId64 " low, %" PRId64 " hi)\n", - hitot * lowtot, lowtot, hitot); + printf("%" PRId64 "\n", hitot * lowtot); return 0; } diff --git a/2023/20/20b.c b/2023/20/20b.c index dc0d6b3..a6f549d 100644 --- a/2023/20/20b.c +++ b/2023/20/20b.c @@ -1,7 +1,7 @@ /* -This one is a bit weird. This program works only for my specific input -(included in this folder). Similarly to number 8, this program outputs -4 numbers and you have to take the lcm of them. +This one is a bit weird. This program works only for my specific input. +Similarly to day 8, this program outputs 4 numbers and you have to +take the lcm of them. I solved it this way: 1. First, using a modified version of the code for part one (graph.c), @@ -19,7 +19,6 @@ I solved it this way: #include #include #include -#include #include #define N 100 @@ -97,11 +96,9 @@ bool isclean(void) { } int64_t period(int node) { - int64_t npush = 0; - do { + int64_t npush; + for (npush = 0; npush == 0 || !isclean(); npush++) sig(node, false); - npush++; - } while (!isclean()); return npush; } -- cgit v1.3