Exemple #1
0
def test_traverse_slope_part_2():
    from functools import reduce

    with open(f"{TEST_FILE_PATH}/test_input.txt") as f:
        test_map = f.read().splitlines()
    trees_found_list = []
    slopes_to_check = [
        [1, 1],
        [3, 1],
        [5, 1],
        [7, 1],
        [1, 2],
    ]
    for slope in slopes_to_check:
        test_tt = TobogganTrajectory(input_map=test_map,
                                     move_x=slope[0],
                                     move_y=slope[1])
        test_tt.traverse_slope()
        trees_found_list.append(test_tt.trees_found)
    assert reduce((lambda x, y: x * y), trees_found_list) == 336
Exemple #2
0
def test_traverse_slope_part_1():
    with open(f"{TEST_FILE_PATH}/test_input.txt") as f:
        test_map = f.read().splitlines()
    test_tt = TobogganTrajectory(input_map=test_map, move_x=3, move_y=1)
    test_tt.traverse_slope()
    assert test_tt.trees_found == 7