aboutsummaryrefslogtreecommitdiff
path: root/2023/07/7a.c
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/07/7a.c
parent6a480c4eb9c96c82a8fd3663f0fbee4d32e56f19 (diff)
downloadaoc-94d0033ed89bb5bfb6500051296892fb7cea6c29.tar.gz
aoc-94d0033ed89bb5bfb6500051296892fb7cea6c29.zip
Small cleanup
Diffstat (limited to '2023/07/7a.c')
-rw-r--r--2023/07/7a.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/2023/07/7a.c b/2023/07/7a.c
index ffc9b5c..7cc4958 100644
--- a/2023/07/7a.c
+++ b/2023/07/7a.c
@@ -11,18 +11,15 @@ int value[255] = {
11 ['T'] = 10, ['J'] = 11, ['Q'] = 12, ['K'] = 13, ['A'] = 14 11 ['T'] = 10, ['J'] = 11, ['Q'] = 12, ['K'] = 13, ['A'] = 14
12}; 12};
13 13
14typedef struct { 14typedef struct { char c[5]; int64_t b; } hand_t;
15 char c[5];
16 int64_t b;
17} hand_t;
18 15
19int strength(hand_t h) { 16int strength(hand_t h) {
20 int i, c2, c1, s, x[15]; 17 int i, c2, c1, s, x[15];
21 18
22 memset(x, 0, 15 * sizeof(int)); 19 memset(x, 0, 15 * sizeof(int));
23 for (i = 0, s = 0; i < 5; i++) { 20 for (i = 0, s = 0; i < 5; i++) {
24 s = s * 15 + value[h.c[i]]; 21 s = s * 15 + value[(int)h.c[i]];
25 x[value[h.c[i]]]++; 22 x[value[(int)h.c[i]]]++;
26 } 23 }
27 for (i = 2, c1 = 0, c2 = 0; i < 15; i++) { 24 for (i = 2, c1 = 0, c2 = 0; i < 15; i++) {
28 if (c1 < x[i]) { 25 if (c1 < x[i]) {

Generated with cgit - Back to sebastiano.tronto.net