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 d91faeed49161c98bf9831375'>refs log tree commit diff
path: root/bin/dash/src/alias.h (unfollow)
Commit message (Expand)Author
2021-02-07Fix cwm window cycling, move big by defaultJune McEnroe
2021-02-07Use class names for Foreground, Background, BorderColorJune McEnroe
2021-02-07Add simple battery status and clock to xsessionJune McEnroe
2021-02-07Set cursor theme and sizeJune McEnroe
2021-02-07Use scrot for up -s if no screencaptureJune McEnroe
2021-02-07Enable mouse acceleration in XJune McEnroe
2021-02-07Set colours for Xt and cwmJune McEnroe
2021-02-07Set urgency on bell in xtermJune McEnroe
2021-02-07Add bindings for brightness controlJune McEnroe
2021-02-07Set X key repeat rateJune McEnroe
2021-02-07Bump font size to 12June McEnroe
2021-02-07Fully configure and rebind cwmJune McEnroe
2021-02-07Add BintiJune McEnroe
2021-02-07Finish configuring xtermJune McEnroe
2021-02-06Enable tapping, reverse scroll, set scaling in wsconsctlJune McEnroe
2021-02-06Set root window to black on purple snowJune McEnroe
2021-02-06Add xmodmap configurationJune McEnroe
2021-02-06Add initial OpenBSD X configurationJune McEnroe
2021-02-06Add xterm output to schemeJune McEnroe