123456789101112131415161718192021222324252627282930 |
- # Python 3.7
-
- import copy
-
- def main():
- instrs = ""
- with open("02in.txt","r") as file:
- instrs = file.readline()
- instrs.strip('\n')
- ints = [int(x) for x in instrs.split(',')]
- default_ints = copy.deepcopy(ints)
- for j in range(100):
- for k in range(100):
- ints = copy.deepcopy(default_ints)
- ints[1] = j
- ints[2] = k
- 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
- if ints[0] == 19690720:
- print((100*j) + k)
- return
-
- if __name__ == "__main__":
- main()
|