def test_solution_part1():
    intcode = read("src/day9/input.txt")
    output = []
    run({"program": intcode}, False, [1], lambda x: output.append(x))
    assert len(output) == 1
    solution = output[0]
    assert solution == 3409270027
def test_solution_part1():
    imagesrc = read("src/day8/input.txt")
    layers = parse_layers(imagesrc, 25, 6)
    layers.sort(key=lambda layer: len(list(filter(lambda x: x == 0, layer))))
    amount_of_1s = len(list(filter(lambda x: x == 1, layers[0])))
    amount_of_2s = len(list(filter(lambda x: x == 2, layers[0])))
    solution = amount_of_1s * amount_of_2s
    assert solution == 2250
Exemplo n.º 3
0
def test_solution_part2():
    imagesrc = read("src/day8/input.txt")
    layers = parse_layers(imagesrc, 25, 6)
    solution = decode(layers)

    # FHJUL
    expected = ("1111010010001101001010000"
                "1000010010000101001010000"
                "1110011110000101001010000"
                "1000010010000101001010000"
                "1000010010100101001010000"
                "1000010010011000110011110")

    assert solution == expected
        ..#####..#.#########
        ####################
        #.####....###.#.#.##
        ##.#################
        #####.##.###..####..
        ..######..##.#######
        ####.##.####...##..#
        .#####..#.######.###
        ##...#.##########...
        #.##########.#######
        .####.#.###.###.#.##
        ....##.##.###..#####
        .#.#.###########.###
        #.#.#.#####.####.###
        ###.##.####.##.#..##"""), ((11, 13), 210)),
    (parse_asteroid_map(read("src/day10/input.txt")), ((11, 19), 253)),

])
def test_find_best_station(asteroids, expected):
    assert find_best_station(asteroids) == expected


@pytest.mark.parametrize("asteroids,station,expected", [
    (parse_asteroid_map(
     """###
        ###
        ###"""), (1, 1), [((1, 0), 0.0), ((2, 0), 45.0), ((2, 1), 90.0), ((2, 2), 135.0), ((1, 2), 180.0), ((0, 2), 225.0), ((0, 1), 270.0), ((0, 0), 315.0)]),
    (parse_asteroid_map(
     """###
        ###
        ###"""), (0, 0), [((1, 0), 90.0), ((2, 0), 90.0), ((2, 1), 116.56505117707799), ((1, 1), 135.0), ((2, 2), 135.0), ((1, 2), 153.43494882292202), ((0, 1), 180.0), ((0, 2), 180.0)])
Exemplo n.º 5
0
def test_solution_part1():
    intcode = read("src/day7/input.txt")
    assert max_thruster_output(intcode) == 38500
def test_solution_part1():
    intcode = read("src/day7/input.txt")
    assert max_thruster_output(intcode, thruster_output_with_feedback_loop,
                               (5, 6, 7, 8, 9)) == 33660560
Exemplo n.º 7
0
def test_solution_part2():
    intcode = read('src/day2/input.txt')
    tokenized = day2.solution_part1.tokenize_program(intcode)

    assert day2.solution_part2.find_solution(tokenized) == 3892