Example #1
0
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)
Example #2
0
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)
Example #3
0
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)
Example #4
0
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))
Example #5
0
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
Example #6
0
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()))
Example #7
0
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))
Example #8
0
def main():
    numbers = read_file("puzzle_inputs.txt")
    part_one(numbers)
    part_two(numbers)
Example #9
0
def part2():
    seat_map = create_seat_map(read_file())
    end_map = apply_all_rounds(seat_map, visibility=True)
    print(count_occupied(end_map))
    pass
Example #10
0
def part2():
    print(find_consecutive_sum(read_file()))
Example #11
0
def part1():
    chain = create_chain(read_file())
    jolt_diffs = get_jolt_diffs(chain)
    print(jolt_diffs[1] * jolt_diffs[3])
    pass
Example #12
0
def part1():
    graph = create_graph(read_file(split_lines=False))
    target = "shiny gold"
    total = can_hold([target], graph)
    log.info(total)
Example #13
0
def main():
    password_entries = read_file()
    # part_one(password_entries)
    part_two(password_entries)
Example #14
0
def part1():
    i, acc = find_loop(read_file())
    print(acc)
Example #15
0
def part1():
    final_pos = move_ship(read_file())
    print(compute_manhattan(final_pos))
Example #16
0
def part2():
    i, acc = fix_loop(read_file())
    print(acc)
    pass
Example #17
0
def part2():
    final_pos = part2_move(read_file())
    print(compute_manhattan(final_pos))
Example #18
0
def part2():
    graph = create_graph(read_file(split_lines=False))
    target = "shiny gold"
    total = count_bags([target], graph)
    log.info(total)
Example #19
0
def part1():
    seat_map = create_seat_map(read_file())
    end_map = apply_all_rounds(seat_map)
    print(count_occupied(end_map))
Example #20
0
def part2():
    chain = create_chain(read_file())
    print(count_all_arrangements(chain))
    pass
Example #21
0
def part1():
    print(find_first_invalid(read_file()))