diff options
author | June McEnroe <june@causal.agency> | 2019-12-06 06:05:06 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2019-12-06 06:05:06 -0500 |
commit | 1d03b35767f95e3b6175fbfe2e33fb801ad3093f (patch) | |
tree | f8d886de4cd3c5d25ba3470436854d81f30eee3b /2019 | |
parent | Solve day 6 part 1 (diff) | |
download | aoc-1d03b35767f95e3b6175fbfe2e33fb801ad3093f.tar.gz aoc-1d03b35767f95e3b6175fbfe2e33fb801ad3093f.zip |
Solve day 6 part 2
Diffstat (limited to '')
-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; + } + } + } } |