def part2(): lines = read_file(split_lines=False) groups = list_from_newline_sep_string(lines) total = 0 for group in groups: total += count_all_yes_group(group) print(total)
def part_two(): valids = 0 total = 0 for passport in make_passports(read_file()): if is_fake_valid(passport, super_valid=True): valids += 1 log.info("VALIDS:") log.info(valids)
def part_one(): valids = 0 total = 0 for passport in make_passports(read_file()): if is_fake_valid(passport): valids += 1 log.info("VALIDS:") log.info(valids)
def part_one(): log.info("--part one--") bp_string_list = read_file() highest_id = -1 for bp_string in bp_string_list: bp = BoardingPass(bp_string.strip()) if bp.seat_id > highest_id: highest_id = bp.seat_id log.info("highest_id: '{}'".format(highest_id))
def traverse(x, y): log.info("slope: {}/{}".format(y, x)) rows = read_file() curpos = 0 trees = 0 for i in range(y, len(rows), y): row = rows[i] curpos = (curpos + x) if curpos > 30: curpos = curpos % 31 if row[curpos] == "#": trees += 1 log.info("-- trees --") log.info(trees) return trees
def part1(): graph = create_graph(read_file(split_lines=False)) colors = {} for key, values in graph.items(): colors[key] = None for value in values: colors[value] = None adjectives = {} names = {} for color in colors.keys(): adjective = color.split(" ")[0] adjectives[adjective] = None name = color.split(" ")[1] names[name] = None from pprint import pprint pprint(sorted(adjectives.keys())) pprint(sorted(names.keys()))
def part_two(): log.info("--part two--") bp_string_list = read_file() seat_map = [[column for column in range(8)] for row in range(128)] for bp_string in bp_string_list: bp = BoardingPass(bp_string.strip()) seat_map[bp.row][bp.column] = "x" for row in range(128): for column in range(8): if seat_map[row][column] != "x": if column == 7: if seat_map[row][column - 1] == "x": print("my_seat_id: {}".format(row * 8 + column)) elif column == 0: if seat_map[row][column + 1] == "x": print("my_seat_id: {}".format(row * 8 + column)) else: if seat_map[row][column+1] == "x" and \ seat_map[row][column-1] == "x": print("my_seat_id: {}".format(row * 8 + column))
def main(): numbers = read_file("puzzle_inputs.txt") part_one(numbers) part_two(numbers)
def part2(): seat_map = create_seat_map(read_file()) end_map = apply_all_rounds(seat_map, visibility=True) print(count_occupied(end_map)) pass
def part2(): print(find_consecutive_sum(read_file()))
def part1(): chain = create_chain(read_file()) jolt_diffs = get_jolt_diffs(chain) print(jolt_diffs[1] * jolt_diffs[3]) pass
def part1(): graph = create_graph(read_file(split_lines=False)) target = "shiny gold" total = can_hold([target], graph) log.info(total)
def main(): password_entries = read_file() # part_one(password_entries) part_two(password_entries)
def part1(): i, acc = find_loop(read_file()) print(acc)
def part1(): final_pos = move_ship(read_file()) print(compute_manhattan(final_pos))
def part2(): i, acc = fix_loop(read_file()) print(acc) pass
def part2(): final_pos = part2_move(read_file()) print(compute_manhattan(final_pos))
def part2(): graph = create_graph(read_file(split_lines=False)) target = "shiny gold" total = count_bags([target], graph) log.info(total)
def part1(): seat_map = create_seat_map(read_file()) end_map = apply_all_rounds(seat_map) print(count_occupied(end_map))
def part2(): chain = create_chain(read_file()) print(count_all_arrangements(chain)) pass
def part1(): print(find_first_invalid(read_file()))