def main(): data = load_input(__file__) bag_rules = {} for line in data: bag_type, rules_str = [x.strip() for x in line.strip()[:-1].split("bags contain")] # Trim and remove period bag_rules[bag_type] = BagRule(bag_type, rules_str) # Make sure there is only one set of rules per bag_type in the input assert(len(bag_rules.keys()) == len(data)) print(part_1(bag_rules)) print(part_2(bag_rules))
def main(): data = [int(line) for line in load_input(__file__)] # Part 1: Find the 2 numbers in the list that sum to 2020, print their product for line in data: if (2020 - line) in data: print(line * (2020 - line)) break # Part 2: Find the 3 numbers in the list that sum to 2020, print their product for i in range(len(data)): for j in range(i + 1, len(data)): x = data[i] y = data[j] if (2020 - x - y) in data[j + 1:]: print(x * y * (2020 - x - y)) return
def main(): data = [int(x) for x in load_input(__file__, 'input.txt')] assert (len(data) == len(set(data))) print(part_1(data)) print(part_2(data))
def main(): data = load_input(__file__) print(part_1(data)) print(part_2(data))
def setUp(self): self.test_data = load_input(__file__, "input_test.txt")
def main(): data = [[c for c in line] for line in load_input(__file__, 'input.txt')] print(part_1(data)) print(part_2(data))
def main(): data = [int(x) for x in load_input(__file__)] invalid_number = part_1(data) print(invalid_number) print(part_2(data, invalid_number))
def main(): data = [BoardingPass(p) for p in load_input(__file__)] print(part_1(data)) print(part_2(data))