You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AdventOfCode19/days/test_day6.py

35 lines
744 B

import os
from typing import Dict
def get_code() -> Dict[str, str]:
inputfile = os.path.join(os.path.dirname(__file__), "input/day6_input")
with open(inputfile) as fp:
return {x[1].rstrip(): x[0] for x in
(y.split(')') for y in fp.readlines())}
def test_day6a():
orbs = get_code()
cnt = 0
for orb in orbs.keys():
n = orb
cnt -= 1
while n:
n = orbs.get(n)
cnt += 1
assert cnt == 241064
def test_day6b():
orbs = get_code()
c = orbs['YOU']
k = []
while c:
k.append(c)
c = orbs.get(c)
c = orbs['SAN']
while c:
k.remove(c) if c in k else k.append(c)
c = orbs.get(c)
assert len(k) == 418