From 86792baf75836bf9d4c4e7cdf6417c8cf0afcf5f Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Fri, 6 Dec 2019 06:05:06 -0500 Subject: Solve day 6 part 2 --- 2019/day06.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/2019/day06.c b/2019/day06.c index fbfda57..2ae79fd 100644 --- a/2019/day06.c +++ b/2019/day06.c @@ -37,4 +37,23 @@ int main(void) { orbits += ancestors(i); } printf("%zu\n", orbits); + + size_t you[2048]; + size_t ylen = 0; + for (size_t i = node("YOU"); i; i = tree[i].parent) { + you[ylen++] = i; + } + size_t san[2048]; + size_t slen = 0; + for (size_t i = node("SAN"); i; i = tree[i].parent) { + san[slen++] = i; + } + for (size_t y = 0; y < ylen; ++y) { + for (size_t s = 0; s < slen; ++s) { + if (you[y] == san[s]) { + printf("%zu\n", y + s - 2); + return 0; + } + } + } } -- cgit 1.4.1 summary refs log tree commit diff
path: root/.gitignore (unfollow)
Commit message (Expand)Author
2021-02-01Remove use of "%n"June McEnroe
2021-02-01Check signals first in the loopJune McEnroe
2020-12-15Log a message when stopping a service waiting to restart 1.1June McEnroe
2020-11-10Refactor unveil calls so errors can be reported properlyJune McEnroe
2020-10-27Do not increment signalsJune McEnroe
2020-10-23Only look up group if one is namedJune McEnroe
2020-10-23Remove default defines of RUNDIR, ETCDIRJune McEnroe
2020-10-23Set shell scripts executable in buildJune McEnroe
2020-10-20Humanize milliseconds if interval is less than 1sJune McEnroe
2020-10-20Humanize restart intervalJune McEnroe
2020-08-17Document default catsit.conf location on OpenBSD 1.0June McEnroe
2020-08-17Template catsit script with RUNDIRJune McEnroe
2020-08-17Clean up includesJune McEnroe
2020-08-17Log service uptime in statusJune McEnroe