コード例 #1
0
ファイル: main.py プロジェクト: TomKite57/advent_of_code_2017
def all_days():
    timer = Advent_Timer()
    for day in menu_options:
        print("Day {}, part 1".format(day))
        menu_options[day].part1("data/day{}.dat".format(day))
        timer.checkpoint_hit()
        print("Day {}, part 2".format(day))
        menu_options[day].part2("data/day{}.dat".format(day))
        timer.checkpoint_hit()
    timer.end_hit()
コード例 #2
0
def star_2(data):
    mask = ""
    memory = {}
    for key, val in data:
        if key == "mask":
            mask = val
            continue
        indices = apply_mask_2(mask, int(key[4:-1]))
        for index in indices:
            memory[index] = int(val)
    return sum(memory.values())


if __name__ == "__main__":
    timer = Advent_Timer()

    # parse input
    data = read_input()
    print("Input parsed!")
    timer.checkpoint_hit()

    # star 1
    star_1_answer = star_1(data)
    print("Star 1: {}".format(star_1_answer))
    timer.checkpoint_hit()

    # star 2
    star_2_answer = star_2(data)
    print("Star 1: {}".format(star_2_answer))
    timer.checkpoint_hit()