diff options
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; + } + } + } } |