1234567891011121314151617181920212223242526 |
- # Python 3.7
-
- def main(debug):
- instrs = ""
- if debug:
- instrs = "1,1,1,4,99,5,6,0,99"
- else:
- with open("02in.txt","r") as file:
- instrs = file.readline()
- instrs.strip('\n')
- ints = [int(x) for x in instrs.split(',')]
- if not debug:
- ints[1] = 12
- ints[2] = 2
- i = 0
- while ints[i] != 99:
- if ints[i] == 1:
- v = ints[ints[i+1]] + ints[ints[i+2]]
- if ints[i] == 2:
- v = ints[ints[i+1]] * ints[ints[i+2]]
- ints[ints[i+3]] = v
- i += 4
- print(ints)
-
- if __name__ == "__main__":
- main(False)
|