Esempio n. 1
0
def run_part2(r: DiagnosticReport) -> int:
    o2_gen_rate = convert_binary_string_to_int(r.get_oxygen_generator_rating())
    co2_scrub_rate = convert_binary_string_to_int(r.get_co2_scrubber_rating())
    return o2_gen_rate * co2_scrub_rate
Esempio n. 2
0
def run_part1(r: DiagnosticReport) -> int:
    gamma_rate = convert_binary_string_to_int(r.get_gamma_rate())
    epsilon_rate = convert_binary_string_to_int(r.get_epsilon_rate())
    return gamma_rate * epsilon_rate
Esempio n. 3
0
from Day03 import PUZZLE_INPUT
from Day03.diagnostics import DiagnosticReport, convert_binary_string_to_int


def run_part1(r: DiagnosticReport) -> int:
    gamma_rate = convert_binary_string_to_int(r.get_gamma_rate())
    epsilon_rate = convert_binary_string_to_int(r.get_epsilon_rate())
    return gamma_rate * epsilon_rate


def run_part2(r: DiagnosticReport) -> int:
    o2_gen_rate = convert_binary_string_to_int(r.get_oxygen_generator_rating())
    co2_scrub_rate = convert_binary_string_to_int(r.get_co2_scrubber_rating())
    return o2_gen_rate * co2_scrub_rate


if __name__ == '__main__':
    report = DiagnosticReport()
    report.load(PUZZLE_INPUT)

    print(f"Part 1: {run_part1(report)}")
    print(f"Part 2: {run_part2(report)}")
Esempio n. 4
0
def test_get_co2_scrubber_rating():
    report = DiagnosticReport()
    report.load(EXAMPLE_INPUT)
    assert report.get_co2_scrubber_rating() == '01010'
Esempio n. 5
0
def test_get_oxygen_generator_rating():
    report = DiagnosticReport()
    report.load(EXAMPLE_INPUT)
    assert report.get_oxygen_generator_rating() == '10111'
Esempio n. 6
0
def test_get_epsilon_rate():
    report = DiagnosticReport()
    report.load(EXAMPLE_INPUT)
    assert report.get_epsilon_rate() == '01001'
Esempio n. 7
0
def test_get_gamma_rate():
    report = DiagnosticReport()
    report.load(EXAMPLE_INPUT)
    assert report.get_gamma_rate() == '10110'