From 8e6fd26e42c80bafb67d6fbb4cc28f7a89427dec Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Mon, 7 Dec 2020 01:55:57 -0500 Subject: Solve day 7 part 2 --- 2020/day07.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/2020/day07.c b/2020/day07.c index 3d97d5f..7445259 100644 --- a/2020/day07.c +++ b/2020/day07.c @@ -37,6 +37,16 @@ static bool canContain(struct Bag *bag, const char *adj, const char *col) { } return false; } +static int containsCount(struct Bag *bag) { + int count = 0; + for (int i = 0; i < 4; ++i) { + if (!bag->cons[i].adj[0]) break; + count += bag->cons[i].cnt; + count += bag->cons[i].cnt + * containsCount(findBag(bag->cons[i].adj, bag->cons[i].col)); + } + return count; +} int main(void) { while (EOF != scanf("%s %s bags contain", bags[len].adj, bags[len].col)) { for ( @@ -57,4 +67,5 @@ int main(void) { if (canContain(&bags[i], "shiny", "gold")) count++; } printf("%d\n", count); + printf("%d\n", containsCount(findBag("shiny", "gold"))); } -- cgit 1.4.1 mary refs log tree commit diff
path: root/bin/1sh/alias.h (unfollow)
Commit message (Collapse)Author
2020-07-31Add scooper to causal.agencyJune McEnroe
2020-07-25Fix setting second title request to GETJune McEnroe
Since 9c845be2797e2047547ec247cb037471aeb48bb0 in curl (7.71.0), setting CURLOPT_NOBODY to 1 sets the request method to HEAD, but setting it back to 0 does not change the method back to GET. Setting CURLOPT_HTTPGET both sets the request method and unsets CURLOPT_NOBODY.
2020-07-20Set pull.rebase trueJune McEnroe
2020-07-18Read from stdin in orderJune McEnroe
2020-07-18Actually fix nvim and doas presence testsJune McEnroe
2020-07-14Install up CGI with mode 700June McEnroe
It should never be served as a regular file.
2020-07-14Check that there is upload dataJune McEnroe
2020-07-14Add CGI upload program for temp.causal.agencyJune McEnroe
2020-07-10Add The Broken KingdomsJune McEnroe
2020-07-08Add facebook and twitter to title user-agentJune McEnroe
This fixes fetching tweets again! https://github.com/thelounge/thelounge/pull/ 3602 (Intentionally breaking the link so GitHub doesn't add a "referenced this PR" thing?)
2020-06-30Tweak causal.agency for mostly no reasonJune McEnroe
2020-06-30Add Ancillary JusticeJune McEnroe
2020-06-26Add password non-manager to planJune McEnroe
I've had this idea for years...
2020-06-26Tweak TF2 sensitivities once moreJune McEnroe
2020-06-19Add note about litterbox bot useJune McEnroe
2020-06-19Publish "IRC suite"June McEnroe
2020-06-17Add errors to link.shJune McEnroe