コード例 #1
0
ファイル: test_day24.py プロジェクト: etfrogers/AdventOfCode
def test_part1():
    with open('input.txt') as f:
        specs = f.read()
    fight = day24.Fight(specs)
    fight.run()

    assert fight.outcome() == 33551
コード例 #2
0
ファイル: test_day24.py プロジェクト: etfrogers/AdventOfCode
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
コード例 #3
0
ファイル: test_day24.py プロジェクト: etfrogers/AdventOfCode
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
コード例 #4
0
ファイル: test_day24.py プロジェクト: etfrogers/AdventOfCode
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
コード例 #5
0
ファイル: test_day24.py プロジェクト: etfrogers/AdventOfCode
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
コード例 #6
0
ファイル: test_day24.py プロジェクト: etfrogers/AdventOfCode
def test_outcome():
    fight = day24.Fight(test_input)
    fight.run()
    assert fight.outcome() == 5216
コード例 #7
0
ファイル: test_day24.py プロジェクト: etfrogers/AdventOfCode
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