def read_operation_sets_value(): input = [OP_Read, 3, 99, 0] output = [OP_Read, 3, 99, 12] read = [] read.append(12) evaluate(input, read) assert_list_equals(input, output)
def write_operation_in_immediate_mode_outputs_value(): input = [100 + OP_Write, 5, 99] output = [100 + OP_Write, 5, 99] read = [] write = evaluate(input, read) assert_list_equals(input, output) assert write[0] == 5
def write_operation_outputs_value(): input = [OP_Write, 2, 99] output = [OP_Write, 2, 99] read = [] write = evaluate(input, read) assert_list_equals(input, output) assert write[0] == 99
def check_lt_eq_gt(input, output): program = [ 3, 21, 1008, 21, 8, 20, 1005, 20, 22, 107, 8, 21, 20, 1006, 20, 31, 1106, 0, 36, 98, 0, 0, 1002, 21, 125, 20, 4, 20, 1105, 1, 46, 104, 999, 1105, 1, 46, 1101, 1000, 1, 20, 4, 20, 1105, 1, 46, 98, 99 ] write = evaluate(program, [input]) assert len(write) == 1 assert write[0] == output
def check_less_than_8_in_position_mode(input, output): program = [3, 9, 7, 9, 10, 9, 4, 9, 99, -1, 8] write = evaluate(program, [input]) assert write[0] == output
def check_equal_to_8_in_position_mode(input, output): program = [3, 9, 8, 9, 10, 9, 4, 9, 99, -1, 8] write = evaluate(program, [input]) assert write[0] == output
def add_operation_in_partial_immediate_mode_correctly_sums(): input = [1000 + OP_Add, 4, -2, 5, 99, 0] output = [1000 + OP_Add, 4, -2, 5, 99, 97] evaluate(input, []) assert_list_equals(input, output)
def day_2_programs_still_valid(input, output): evaluate(input, []) assert_list_equals(input, output)
def jump_test_in_immediate_mode(input, output): program = [3, 3, 1105, -1, 9, 1101, 0, 0, 12, 4, 12, 99, 1] write = evaluate(program, [input]) assert write[0] == output
def jump_test_in_position_mode(input, output): program = [3, 12, 6, 12, 15, 1, 13, 14, 13, 4, 13, 99, -1, 0, 1, 9] write = evaluate(program, [input]) assert write[0] == output
def check_less_than_8_in_immediate_mode(input, output): program = [3, 3, 1107, -1, 8, 3, 4, 3, 99] write = evaluate(program, [input]) assert write[0] == output
def check_equal_to_8_in_immediate_mode(input, output): program = [3, 3, 1108, -1, 8, 3, 4, 3, 99] write = evaluate(program, [input]) assert write[0] == output