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(+) (limited to '2019') 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