aboutsummaryrefslogtreecommitdiff
path: root/2023/20
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2023-12-25 17:56:34 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2023-12-25 17:56:34 +0100
commit94d0033ed89bb5bfb6500051296892fb7cea6c29 (patch)
tree245eac2218310c958c2df2fad5109ea4f7b2a9d9 /2023/20
parent6a480c4eb9c96c82a8fd3663f0fbee4d32e56f19 (diff)
downloadaoc-94d0033ed89bb5bfb6500051296892fb7cea6c29.tar.gz
aoc-94d0033ed89bb5bfb6500051296892fb7cea6c29.zip
Small cleanup
Diffstat (limited to '2023/20')
-rw-r--r--2023/20/20a.c4
-rw-r--r--2023/20/20b.c13
2 files changed, 6 insertions, 11 deletions
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 @@
1#include <inttypes.h> 1#include <inttypes.h>
2#include <stdbool.h> 2#include <stdbool.h>
3#include <stdio.h> 3#include <stdio.h>
4#include <stdlib.h>
5#include <string.h> 4#include <string.h>
6 5
7#define N 100 6#define N 100
@@ -95,7 +94,6 @@ int main() {
95 for (int i = 0; i < 1000; i++) 94 for (int i = 0; i < 1000; i++)
96 pushbutton(); 95 pushbutton();
97 96
98 printf("%" PRId64 " (%" PRId64 " low, %" PRId64 " hi)\n", 97 printf("%" PRId64 "\n", hitot * lowtot);
99 hitot * lowtot, lowtot, hitot);
100 return 0; 98 return 0;
101} 99}
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 @@
1/* 1/*
2This one is a bit weird. This program works only for my specific input 2This one is a bit weird. This program works only for my specific input.
3(included in this folder). Similarly to number 8, this program outputs 3Similarly to day 8, this program outputs 4 numbers and you have to
44 numbers and you have to take the lcm of them. 4take the lcm of them.
5 5
6I solved it this way: 6I solved it this way:
71. First, using a modified version of the code for part one (graph.c), 71. First, using a modified version of the code for part one (graph.c),
@@ -19,7 +19,6 @@ I solved it this way:
19#include <inttypes.h> 19#include <inttypes.h>
20#include <stdbool.h> 20#include <stdbool.h>
21#include <stdio.h> 21#include <stdio.h>
22#include <stdlib.h>
23#include <string.h> 22#include <string.h>
24 23
25#define N 100 24#define N 100
@@ -97,11 +96,9 @@ bool isclean(void) {
97} 96}
98 97
99int64_t period(int node) { 98int64_t period(int node) {
100 int64_t npush = 0; 99 int64_t npush;
101 do { 100 for (npush = 0; npush == 0 || !isclean(); npush++)
102 sig(node, false); 101 sig(node, false);
103 npush++;
104 } while (!isclean());
105 return npush; 102 return npush;
106} 103}
107 104

Generated with cgit - Back to sebastiano.tronto.net