def test_phase1(self): with open(f'{self.input_loc}/day2') as inp: program = Program(inp.read()) program.code[1] = 12 program.code[2] = 2 intcode(program) self.assertEqual(program.code[0], 6327510)
def test_part1_multiply(): assert intcode("2,3,0,3,99") == "2,3,0,6,99"
def test_part1_sum(): assert intcode("1,0,0,0,99") == "2,0,0,0,99"
def test_part1_example(): assert (intcode("1,9,10,3,2,3,11,0,99,30,40,50") == "3500,9,10,70,2,3,11,0,99,30,40,50")
def test_part1_multiply_two_commands(): assert intcode("1,1,1,4,99,5,6,0,99") == "30,1,1,4,2,5,6,0,99"
def test_part1_multiply_99(): assert intcode("2,4,4,5,99,0") == "2,4,4,5,99,9801"
def test_negative(self): program = Program('1101,100,-1,4,0') intcode(program) # Test 100+ -1 at pos 4 self.assertEqual(program.code[4], 99)
def test_immediate_mul(self): program = Program('1002,4,3,4,33') intcode(program) # 33 * 3 stored at pos 4 self.assertEqual(program.code[4], 99)
def test_sum_mul(self): program = Program('1,1,1,4,99,5,6,0,99') intcode(program) # Test 1+1 into pos 4, which makes 5*6 into pos 0 self.assertEqual(program.code[0], 30)
def test_mul2(self): program = Program('2,4,4,5,99,0') intcode(program) # Test 99*99 = 9801 at pos 5 self.assertEqual(program.code[5], 9801)
def test_mul(self): program = Program('2,3,0,3,99') intcode(program) # Test 3*2, stored at pos 3 self.assertEqual(program.code[3], 6)
def test_sum(self): code = '1,0,0,0,99' program = Program(code) intcode(program) # Test 1+1, stored at pos 0 self.assertEqual(program.code[0], 2)