Exemple #1
0
def test_part1():
    with open('input.txt') as f:
        specs = f.read()
    fight = day24.Fight(specs)
    fight.run()

    assert fight.outcome() == 33551
Exemple #2
0
def test_part2():
    with open('input.txt') as f:
        specs = f.read()
    fight = day24.Fight(specs)
    boost = fight.find_min_boost()
    assert boost == 77
    fight.run_with_boost(boost)
    assert fight.outcome() == 760
Exemple #3
0
def test_parsing():
    fight = day24.Fight(test_input)
    assert len(fight['Immune System'].groups) == 2
    assert len(fight['Infection'].groups) == 2
    assert fight['Immune System'][1].attack_damage == 4507
    assert fight['Immune System'][2].units == 989
    assert 'radiation' in fight['Infection'][2].immunities
    assert fight['Infection'][1].initiative == 1
Exemple #4
0
def test_min_boost():
    fight = day24.Fight(test_input)
    boost = fight.find_min_boost()
    assert boost == 1570
    fight.run_with_boost(boost)
    assert fight.outcome() == 51
Exemple #5
0
def test_boost():
    fight = day24.Fight(test_input)
    fight.apply_boost(1570)
    fight.run()
    assert fight.get_winner().name == 'Immune System'
    assert fight.outcome() == 51
Exemple #6
0
def test_outcome():
    fight = day24.Fight(test_input)
    fight.run()
    assert fight.outcome() == 5216
Exemple #7
0
def test_fighting():
    fight = day24.Fight(test_input)
    outputs = test_output.split('\n\n\n')
    _, damage_spec, round_spec = outputs[0].split('\n\n')
    yield check_damage, fight, damage_spec
    yield check_round, fight, round_spec