Esempio n. 1
0
def test_day_5_jump_pos():
    test_prog = [3, 12, 6, 12, 15, 1, 13, 14, 13, 4, 13, 99, -1, 0, 1, 9]
    ic = IntcodeComputer(initial_state=test_prog)
    res = True
    output = []
    while res is not False:
        res = ic.run_computer()
        # print(res)
        output.append(res)
        if res is True:
            ic.next_input = 5
    print(output)
Esempio n. 2
0
def test_day_5_equal_to():
    test_prog = [3, 9, 8, 9, 10, 9, 4, 9, 99, -1, 8]
    ic = IntcodeComputer(initial_state=test_prog)
    res = True
    output = []
    my_input = 5
    ic.next_input = my_input
    while res is not False:
        res = ic.run_computer()
        # print(res)
        output.append(res)
    assert res is False  # End of program
    assert len(output[:-1]) == 1
    assert output[0] == 0
Esempio n. 3
0
def test_day_5_prog_1():
    test_prog = [3, 0, 4, 0, 99]
    ic = IntcodeComputer(initial_state=test_prog)
    res = True
    output = []
    my_input = 5
    while res is not False:
        res = ic.run_computer()
        # print(res)
        output.append(res)
        if res is True:
            ic.next_input = my_input
    assert res is False  # End of program
    assert len(output[:-1]) == 2
    assert output[0] is True
    assert output[1] == my_input
Esempio n. 4
0
def test_boost_program():
    with open("boost.txt") as input_file:
        input_string = input_file.read()
        boost_program = [int(x) for x in input_string.split(sep=',')]
    ic = IntcodeComputer(initial_state=boost_program)
    ic.next_input = 1
    res = True
    output = []
    while res is not False:
        res = ic.run_computer()
        # print(res)
        output.append(res)
    assert res is False  # End of program
    print(output)
    assert len(output[:-1]) == 1  # Boost should only produce a single integer
    my_correct_res = 3518157894  # for my input, this is what boost should output (when input 1)
    assert output[0] == my_correct_res
Esempio n. 5
0
input_path = "input.txt"
with open(input_path) as input_file:
    input_string = input_file.read()
    intcode_program_list = [int(x) for x in input_string.split(sep=',')]

from intcode_computer.intcode_computer import IntcodeComputer

ic = IntcodeComputer(initial_state=intcode_program_list)

res = True
output = []
while res is not False:
    res = ic.run_computer()
    output.append(res)
    if res is True:
        ic.next_input = 2

print(output)