def main(): input_lines = [line.strip() for line in read_lines(FILEPATH)] syntax_error_score, incomplete_lines = calculate_syntax_error_score( input_lines) print(f"Part 1 -- {syntax_error_score}") print(f"Part 2 -- {calculate_middle_completion_score(incomplete_lines)}")
def main(): dots, fold_instructions = parse_input( [line.strip() for line in read_lines(FILEPATH)]) print(f"Part 1 -- {len(fold_origami(dots, fold_instructions[0:1]))}") print("Part 2 -- BLHFJPJF") print_origami_code(fold_origami(dots, fold_instructions))
def main(): cave_connections_raw: List[Tuple[str, str]] = [ tuple(line.strip().split("-")) for line in read_lines(FILEPATH) ] cave_map: Dict[str, List[str]] = create_cave_map(cave_connections_raw) print(f"Part 1 -- {find_number_of_cave_traversals(cave_map, True)}") # I was struggling on part 2 since my if-checks were out of order; thanks to Jonathan Paulson for the help on YouTube! print(f"Part 2 -- {find_number_of_cave_traversals(cave_map, False)}")
def main(): input_lines: List[str] = [line.strip() for line in read_lines(FILEPATH)] bingo_input: List[str] = [line.split() for line in input_lines[2:]] nums_to_be_called = [int(i) for i in input_lines[0].split(",")] print( f"Part 1 -- {find_first_bingo_winner(BingoBoard.create_bingo_boards_list(bingo_input), nums_to_be_called)}" ) print( f"Part 2 -- {find_last_bingo_winner(BingoBoard.create_bingo_boards_list(bingo_input), nums_to_be_called)}" )
def main(): line_segments = [ line.strip().split(" -> ") for line in read_lines(FILEPATH) ] line_segments: List[List[Tuple[int, int]]] = [[ tuple(int(x) for x in segment[0].split(",")), tuple(int(x) for x in segment[1].split(",")) ] for segment in line_segments] print( f"Part 1 -- {get_num_overlapping_points(create_segment_map(line_segments, True))}" ) print( f"Part 2 -- {get_num_overlapping_points(create_segment_map(line_segments, False))}" )
def main(): input_lines = [line.strip() for line in read_lines(FILEPATH)] polymer_template: str = input_lines[0] pair_insertion_rules = [[s for s in line.split(" -> ")] for line in input_lines[2:]] pair_insertion_rules: Dict[str, str] = { s[0]: s[1] for s in pair_insertion_rules } print( f"Part 1 -- {calculate_most_minus_least_common_element(substitute_polymer_rules(polymer_template, pair_insertion_rules, 10))}" ) print( f"Part 2 -- {calculate_most_minus_least_common_element_dict_version(substitute_polymer_rules_optimized(polymer_template, pair_insertion_rules, 40))}" )
def main(): input_lines = [line for line in read_lines(FILEPATH)] print(f"Part 1 -- {}") print(f"Part 2 -- {}")
def main(): input_lines = [line.strip() for line in read_lines(FILEPATH)] print(f"Part 1 -- {calculate_power_consumption(input_lines)}") print(f"Part 2 -- {calculate_life_support_rating(input_lines)}")
def main(): signal_patterns, output_values = parse_input([line.strip() for line in read_lines(FILEPATH)]) print(f"Part 1 -- {count_easy_digits(output_values)}") print(f"Part 2 -- {sum_all_output_values(signal_patterns, output_values)}")
def main(): positions: List[int] = [int(x) for x in read_lines(FILEPATH)[0].split(",")] print(f"Part 1 -- {calculate_min_fuel_consumption(positions, True)}") print(f"Part 2 -- {calculate_min_fuel_consumption(positions, False)}")
def main(): raw_fish_frequencies: List[int] = [[int(x) for x in line.strip().split(",")] for line in read_lines(FILEPATH)][0] deduped_frequencies = create_deduped_fish_frequencies_list(raw_fish_frequencies) print(f"Part 1 -- {simulate_fish(deduped_frequencies, 80)}") print(f"Part 2 -- {simulate_fish(deduped_frequencies, 256)}")
def main(): input_tokens = [Token(line.strip()) for line in read_lines(FILEPATH)] print(f"Part 1 -- {calculate_product(input_tokens)}") print(f"Part 2 -- {calculate_aim_product(input_tokens)}")