def main(): pairs = load_patterns(PARENT_CHILD_REGEX, "input/d06.txt") counter = OrbitCounter() for pair in pairs: counter.add(pair[0], pair[1]) print("Orbits: {0}".format(counter.get_orbits())) print("Transfers: {0}".format(counter.get_hops("YOU", "SAN")))
def load_signal_sets(path: str) -> List[SignalSet]: split_regex = re.compile('^([a-g ]+)\\| ([a-z ]+)$') signals = [ SignalSet(signals=signals.split(), display=display.split()) for signals, display in load_patterns(split_regex, path) ] return signals
def test_load_valid(self): groups = load_patterns(SPLIT_REGEX, GetTestFilePath( "input/patterns/validPatterns.txt")) expected = [ ("1", "3", "a", "abcde"), ("1", "3", "b", "cdefg"), ("2", "9", "c", "ccccccccc") ] self.assertListEqual(groups, expected)
def main(): passes = load_patterns(SPLIT_REGEX, "input/d02.txt") count = 0 count2 = 0 for pass_to_test in passes: if is_pass_valid(pass_to_test): count += 1 if is_pass_valid_part_2(pass_to_test): count2 += 1 print("Valid: {0}".format(count)) print("Valid (2): {0}".format(count2))
def test_load_invalidLine(self): with self.assertRaises(UnexpectedLineFormat) as context: load_patterns(SPLIT_REGEX, GetTestFilePath("input/patterns/invalidLine"))
def loader(): load_patterns( SPLIT_REGEX, GetTestFilePath("input/patterns/validPatterns.txt"), num_results=4)