예제 #1
0
def test_load_input():
    """Test the load_input function"""
    processed_input = load_input("input.txt")
    assert processed_input[:2] == [
        ("1001X0X00110011X01X1000110100011000X", 5228, 409649),
        ("1001X0X00110011X01X1000110100011000X", 64037, 474625),
    ]
예제 #2
0
def test_load_input():
    expected_algorithm = "..#.#..#####.#.#.#.###.##.....###.##.#..###.####..#####..#....#..#..##..###..######.###...####..#..#####..##..#.#####...##.#.#..#.##..#.#......#.###.######.###.####...#.##.##..#..#..#####.....#.#....###..#.##......#.....#..#..#..##..#...##.######.####.####.#.#...#.......#..#.#.#...####.##.#......#..#...##.#.##..#...##.#.##..###.#......#.#.......#.#.#.####.###.##...#.....####.#..#..#.##.#....##..#.####....##...##..#...#......#.#.......#.......##..####..#...#.#.#...##..#.#..###..#####........#..####......#..#"
    expected_image = [
        ["#", ".", ".", "#", "."],
        ["#", ".", ".", ".", "."],
        ["#", "#", ".", ".", "#"],
        [".", ".", "#", ".", "."],
        [".", ".", "#", "#", "#"],
    ]
    actual_algorithm, actual_image = load_input("sample_input.txt")
    assert actual_algorithm == expected_algorithm
    assert actual_image == expected_image
예제 #3
0
def test_load_input():
    """Test load input function"""
    # fmt: off
    assert load_input("test_input.txt") == (
        {
            "class": {1, 2, 3, 5, 6, 7},
            "row": {
                6, 7, 8, 9, 10, 11, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
                44
            },
            "seat": {
                13,
                14,
                15,
                16,
                17,
                18,
                19,
                20,
                21,
                22,
                23,
                24,
                25,
                26,
                27,
                28,
                29,
                30,
                31,
                32,
                33,
                34,
                35,
                36,
                37,
                38,
                39,
                40,
                45,
                46,
                47,
                48,
                49,
                50,
            },
        },
        [7, 1, 14],
        [[7, 3, 47], [40, 4, 50], [55, 2, 20], [38, 6, 12]],
    )
예제 #4
0
def test_load_input():
    expected = [
        {
            (404, -588, -901),
            (528, -643, 409),
            (-838, 591, 734),
        },
        {
            (686, 422, 578),
            (605, 423, 415),
            (515, 917, -361),
        },
        {
            (649, 640, 665),
            (682, -795, 504),
            (-784, 533, -524),
        },
    ]
    actual = load_input("loading_sample.txt")
    assert actual == expected
예제 #5
0
def test_input():
    """Load the test input for testing"""
    return load_input("test_input.txt")
예제 #6
0
"""Day 19 tests"""
from solution import load_input, part1

test_rules, test_msgs = load_input("test_input.txt")


def test_part1(rules=test_rules, msgs=test_msgs, expected=2):
    """Test part1 function"""
    assert part1(rules, msgs) == expected
예제 #7
0
def test_find_max_scanner_distance():
    scanners = load_input("sample_input.txt")
    _, scanner_locations = merge_scanners_lazy(scanners)
    assert find_max_scanner_distance(scanner_locations) == 3621
예제 #8
0
def test_merge_scanners_lazy_scanner_locations():
    scanners = load_input("sample_input.txt")
    _, scanner_locations = merge_scanners_lazy(scanners)
    assert scanner_locations[0] == (0, 0, 0)
    assert scanner_locations[2] == (1105, -1205, 1229)
    assert scanner_locations[3] == (-92, -2380, -20)
예제 #9
0
def test_merge_scanners_lazy_merged_point():
    scanners = load_input("sample_input.txt")
    merged, _ = merge_scanners_lazy(scanners)
    assert len(merged) == 79
예제 #10
0
def test_try_match_scanner_pair_from_sample(a, b):
    scanners = load_input("sample_input.txt")
    assert _try_match_scanner_pair(scanners[a], scanners[b])
예제 #11
0
def test_find_overlapping_pairs():
    scanners = load_input("sample_input.txt")
    pairs = _find_overlapping_pairs(scanners)
    assert len(pairs) >= len(scanners) - 1
예제 #12
0
def test_full():
    expected_lit = 35
    algorithm, image = load_input("sample_input.txt")
    end_image = apply_algorithm_n(algorithm, image, 2)
    actual_lit = count_lit_pixels(end_image)
    assert actual_lit == expected_lit