diff options
author | June McEnroe <june@causal.agency> | 2019-12-06 06:05:06 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-11-22 00:14:26 -0500 |
commit | 86792baf75836bf9d4c4e7cdf6417c8cf0afcf5f (patch) | |
tree | 0f954eb5dbdfe815a2eb593dd1b35fe312b1ae8c /2019 | |
parent | Solve day 6 part 1 (diff) | |
download | aoc-86792baf75836bf9d4c4e7cdf6417c8cf0afcf5f.tar.gz aoc-86792baf75836bf9d4c4e7cdf6417c8cf0afcf5f.zip |
Solve day 6 part 2
Diffstat (limited to '2019')
-rw-r--r-- | 2019/day06.c | 19 |
1 files changed, 19 insertions, 0 deletions
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; + } + } + } } |