From 64cab0a735de8d8faaadf1dcce86444fed22a395 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Sat, 4 Dec 2021 18:10:18 -0500 Subject: Solve day 4 part 2 This is hilariously bad. --- 2021/day04.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to '2021') 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); } -- cgit 1.4.1 mp;id=ffbf1635f5be94eda4ee857d51a51a1564235f5d'>refs log tree commit diff
path: root/.gitignore (unfollow)
Commit message (Expand)Author
2019-10-25Use produce/consume words for ring bufferJune McEnroe
2019-10-25Implement client reading from ring bufferJune McEnroe
2019-10-25Implement ringDiff and ringReadJune McEnroe
2019-10-24Remove manual client naming from manual pageJune McEnroe
2019-10-24Zero entire Client structJune McEnroe
2019-10-24Register readers by client usernamesJune McEnroe
2019-10-24Unset non-blocking on clientsJune McEnroe
2019-10-24Intercept client QUITJune McEnroe
2019-10-24Only set NeedCapEnd if unregisteredJune McEnroe
2019-10-24Set client-side origin to irc.invalidJune McEnroe
2019-10-24Factor out client-side origin nameJune McEnroe
2019-10-24Intercept all CAP commands from clientsJune McEnroe
2019-10-24Ignore further CAP ENDJune McEnroe
2019-10-24Implement client CAP for server-timeJune McEnroe
2019-10-24Implement ringWriteJune McEnroe
2019-10-24Make clientFormat publicJune McEnroe
2019-10-24Make serverFormat publicJune McEnroe
2019-10-24Rename some thingsJune McEnroe
2019-10-23Add ISUPPORT draft to STANDARDSJune McEnroe
2019-10-23Track own originJune McEnroe
2019-10-23Track channels and sync ISUPPORTJune McEnroe
2019-10-23Track nick changesJune McEnroe
2019-10-23Rename Command to MessageJune McEnroe
2019-10-23Synchronize state after client registrationJune McEnroe
2019-10-23Send to server if client has no needsJune McEnroe
2019-10-23Implement some amount of client connectionJune McEnroe
2019-10-23Set clients non-blockingJune McEnroe
2019-10-23Clean up state.c and factor out parsingJune McEnroe
2019-10-23Respond to pingsJune McEnroe
2019-10-23Add verbose flagJune McEnroe
2019-10-23Set NOSIGPIPE on server connectionJune McEnroe
2019-10-23Set an initial loop capJune McEnroe
2019-10-23Fix rest parsingJune McEnroe
2019-10-23Add dynamic poll listJune McEnroe
2019-10-23Don't assume commands have targets and handle ERRORJune McEnroe
2019-10-23Clean up state somewhatJune McEnroe
2019-10-23Actually send the buffer...June McEnroe
2019-10-23Add stateJune McEnroe