예제 #1
0
def run_part_2(in_file: str, debug: bool = False) -> int:
    pretty.printHeader(DAY, 2, inspect.stack()[0].function, in_file)
    result = 0
    seats = loadingUtils.importTo2DArray(in_file)
    result = run_until_stable2(seats)
    print("Result = {}".format(result))
    return result
예제 #2
0
def run_part_1(in_file: str, debug: bool = False) -> int:
    pretty.printHeader(DAY, 1, inspect.stack()[0].function, in_file)
    result = 0
    treemap = loadingUtils.importTo2DArray(in_file)
    if debug: pretty.print2DMap(treemap)
    path = get_path_traverse_diagonal(treemap, (1, 3))
    result = len(list(filter(lambda x: x == "#", path)))
    print("I hit {} trees!".format(result))
    return result
예제 #3
0
def run_part_2(in_file: str, debug: bool = False) -> int:
    pretty.printHeader(DAY, 2, inspect.stack()[0].function, in_file)
    result = 0
    start_map = loadingUtils.importTo2DArray(in_file)
    final_map = run2(start_map, 6)
    result = count_map(final_map)
    # code here
    print("Result = {}".format(result))
    return result
예제 #4
0
def run_part_2(in_file: str, debug: bool = False) -> int:
    pretty.printHeader(DAY, 2, inspect.stack()[0].function, in_file)
    result = 0
    treemap = loadingUtils.importTo2DArray(in_file)
    if debug: pretty.print2DMap(treemap)
    list_of_directions = [(1, 1), (1, 3), (1, 5), (1, 7), (2, 1)]
    number_of_trees_per_run = []
    for direction in list_of_directions:
        number_of_trees_per_run.append(
            len(
                list(
                    filter(lambda x: x == "#",
                           get_path_traverse_diagonal(treemap, direction)))))
    print(number_of_trees_per_run)
    result = functools.reduce(lambda x, y: x * y, number_of_trees_per_run)
    print("Result = {}".format(result))
    return result
예제 #5
0
def test_view_4():
    seatmap = loadingUtils.importTo2DArray(INPUTFOLDER+"/test4")
    print("aaaaaaaaa + " + str(seatmap[3][3]))
    cnt = day.count_occupied_neighbours_in_sight(seatmap, 3, 3 )
    assert cnt == 0
예제 #6
0
def test_view_2():
    seatmap = loadingUtils.importTo2DArray(INPUTFOLDER+"/test2")
    print(seatmap[4][3])
    cnt = day.count_occupied_neighbours_in_sight(seatmap, 4, 3 )
    assert cnt == 8