summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-12-04 18:10:18 -0500
committerJune McEnroe <june@causal.agency>2021-12-04 18:10:18 -0500
commitd5e061586e043507d4c7220e8f9351bfa20af834 (patch)
treea1eb4894aff0a694e427c9ec02bae3953cdf1e37
parentSolve day 4 part 1 (diff)
downloadaoc-d5e061586e043507d4c7220e8f9351bfa20af834.tar.gz
aoc-d5e061586e043507d4c7220e8f9351bfa20af834.zip
Solve day 4 part 2
This is hilariously bad.
-rw-r--r--2021/day04.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/2021/day04.c b/2021/day04.c
index 88bf80f..c414f81 100644
--- a/2021/day04.c
+++ b/2021/day04.c
@@ -50,4 +50,25 @@ int main(void) {
 		if (!(boards[w].mark & (1 << i))) sum += boards[w].nums[i];
 	}
 	printf("%d\n", sum * num);
+	for (; i < n; ++i) {
+		for (int j = 0; j < len; ++j) {
+			for (int k = 0; k < 25; ++k) {
+				if (boards[j].nums[k] == nums[i]) {
+					int won = win(&boards[j]);
+					boards[j].mark |= 1 << k;
+					if (!won && win(&boards[j])) {
+						w = j;
+						num = nums[i];
+						sum = 0;
+						for (int i = 0; i < 25; ++i) {
+							if (!(boards[w].mark & (1 << i))) {
+								sum += boards[w].nums[i];
+							}
+						}
+					}
+				}
+			}
+		}
+	}
+	printf("%d\n", sum * num);
 }
an title='2020-02-17 10:33:00 -0500'>2020-02-17Add Four Tet — HandsJune McEnroe 2020-02-12Simplify macOS notify-sendJune McEnroe 2020-02-12Add imbox and notemap to pageJune McEnroe 2020-02-12Collapse simple linksJune McEnroe 2020-02-12Move catgirl up the pageJune McEnroe 2020-02-12Update catgirl pty grabJune McEnroe 2020-02-12Link to cgit /about pages where appropriateJune McEnroe 2020-02-11Separate LINKS from BINS for html to workJune McEnroe 2020-02-11Add margin to Bl-bullet itemsJune McEnroe 2020-02-10Match URLs inside parens or with paired parens insideJune McEnroe 2020-02-10Duplicate effective URL before passing it back to curlJune McEnroe 2020-02-09Add To Be Taught, If FortunateJune McEnroe 2020-02-04Add The Future of Another TimelineJune McEnroe 2020-01-31Reorganize the Makefile for the umpteenth timeJune McEnroe 2020-01-28Change scout sensitivity to 1.4June McEnroe 2020-01-28Import shows.txtJune McEnroe