text: import aoc_common as ac
  from aocd.models import Puzzle
  
  puzzle = Puzzle(year=2019, day=5)
  
  # print(puzzle.input_data)
  
  test_input = "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"
  
  intcode_list = puzzle.input_data.split(",")
  
  test_list = test_input.split(",")
  
  original_intcode_list = [ int(x) for x in intcode_list]
  
  
  def intcode_computer(intcode_list, _input):
      counter = 0
      input = _input
      try:
          while True:
  
              item = intcode_list[counter]
  
              ones = int(str(item)[-1])
              tens = int(str(item // 10)[-1])
              hundreds = int(str(item // 100)[-1])
              thousands = int(str(item // 1000)[-1])
  
              if ones == 1:
                  if hundreds == 1:
                      param1 = intcode_list[counter + 1]
                  else:
                      position = intcode_list[counter + 1]
                      param1 = intcode_list[position]
  
                  if thousands == 1:
                      param2 = intcode_list[counter + 2]
                  else:
                      param2 = intcode_list[intcode_list[counter + 2]]
  
                  intcode_list[intcode_list[counter + 3]] = param1 + param2
                  counter += 4
  
              if ones == 2:
                  if hundreds == 1:
                      param1 = intcode_list[counter + 1]
                  else:
                      param1 = intcode_list[intcode_list[counter + 1]]
  
                  if thousands == 1:
                      param2 = intcode_list[counter + 2]
                  else:
                      param2 = intcode_list[intcode_list[counter + 2]]
  
                  intcode_list[intcode_list[counter + 3]] = param1 * param2
                  counter += 4
  
              if ones == 3:
                  # if hundreds == 1:
                  #     param1 = intcode_list[counter + 1]
                  # else:
                  #     param1 = intcode_list[intcode_list[counter + 1]]
                  param1 = intcode_list[counter + 1]
                  intcode_list[param1] = input
                  counter += 2
  
              if ones == 4:
                  if hundreds == 1:
                      param1 = intcode_list[counter + 1]
                  else:
                      param1 = intcode_list[intcode_list[counter + 1]]
  
                  print(param1)
                  counter += 2
  
              if ones == 5:
                  if hundreds == 1:
                      param1 = intcode_list[counter + 1]
                  else:
                      param1 = intcode_list[intcode_list[counter + 1]]
  
                  if thousands == 1:
                      param2 = intcode_list[counter + 2]
                  else:
                      param2 = intcode_list[intcode_list[counter + 2]]
  
                  if param1 == 0:
                      counter += 3
                  else:
                      counter = param2
  
              if ones == 6:
                  if hundreds == 1:
                      param1 = intcode_list[counter + 1]
                  else:
                      param1 = intcode_list[intcode_list[counter + 1]]
  
                  if thousands == 1:
                      param2 = intcode_list[counter + 2]
                  else:
                      param2 = intcode_list[intcode_list[counter + 2]]
  
                  if param1 != 0:
                      counter += 3
                  else:
                      counter = param2
  
              if ones == 7:
                  if hundreds == 1:
                      param1 = intcode_list[counter + 1]
                  else:
                      param1 = intcode_list[intcode_list[counter + 1]]
  
                  if thousands == 1:
                      param2 = intcode_list[counter + 2]
                  else:
                      param2 = intcode_list[intcode_list[counter + 2]]
  
                  if param1 < param2:
                      intcode_list[intcode_list[counter + 3]] = 1
                  else:
                      intcode_list[intcode_list[counter + 3]] = 0
  
                  counter += 4
  
              if ones == 8:
                  if hundreds == 1:
                      param1 = intcode_list[counter + 1]
                  else:
                      param1 = intcode_list[intcode_list[counter + 1]]
  
                  if thousands == 1:
                      param2 = intcode_list[counter + 2]
                  else:
                      param2 = intcode_list[intcode_list[counter + 2]]
  
                  if param1 == param2:
                      intcode_list[intcode_list[counter + 3]] = 1
                  else:
                      intcode_list[intcode_list[counter + 3]] = 0
  
                  counter += 4
  
              if ones == 9 and tens == 9:
                  print("Complete")
                  break
      except:
          print(counter)
  
  
  if __name__ == '__main__':
      print(intcode_computer(original_intcode_list.copy(), 1))
      print(intcode_computer(original_intcode_list.copy(), 5))
  