Advertisement
R2bEEaton

Untitled

Dec 15th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.23 KB | None | 0 0
  1. thing = "1102,34463338,34463338,63,1007,63,34463338,63,1005,63,53,1101,3,0,1000,109,988,209,12,9,1000,209,6,209,3,203,0,1008,1000,1,63,1005,63,65,1008,1000,2,63,1005,63,904,1008,1000,0,63,1005,63,58,4,25,104,0,99,4,0,104,0,99,4,17,104,0,99,0,0,1102,1,31,1008,1101,682,0,1027,1101,0,844,1029,1102,29,1,1001,1102,1,22,1014,1101,0,21,1011,1102,428,1,1025,1101,0,433,1024,1101,0,38,1019,1102,1,37,1016,1102,35,1,1017,1102,39,1,1018,1102,32,1,1000,1102,23,1,1012,1102,1,329,1022,1102,26,1,1006,1102,1,24,1003,1102,28,1,1005,1102,36,1,1010,1102,34,1,1004,1101,0,1,1021,1102,326,1,1023,1101,33,0,1015,1101,20,0,1002,1101,0,25,1007,1101,0,853,1028,1102,27,1,1009,1102,1,30,1013,1101,689,0,1026,1102,1,0,1020,109,12,2108,30,-3,63,1005,63,201,1001,64,1,64,1105,1,203,4,187,1002,64,2,64,109,-9,2101,0,6,63,1008,63,29,63,1005,63,227,1001,64,1,64,1106,0,229,4,209,1002,64,2,64,109,-6,1208,5,22,63,1005,63,249,1001,64,1,64,1106,0,251,4,235,1002,64,2,64,109,13,21107,40,41,8,1005,1018,273,4,257,1001,64,1,64,1105,1,273,1002,64,2,64,109,-11,2102,1,8,63,1008,63,25,63,1005,63,299,4,279,1001,64,1,64,1105,1,299,1002,64,2,64,109,15,1205,7,317,4,305,1001,64,1,64,1105,1,317,1002,64,2,64,109,10,2105,1,-1,1105,1,335,4,323,1001,64,1,64,1002,64,2,64,109,-22,1202,1,1,63,1008,63,24,63,1005,63,357,4,341,1106,0,361,1001,64,1,64,1002,64,2,64,109,13,1206,6,373,1106,0,379,4,367,1001,64,1,64,1002,64,2,64,109,11,1206,-6,393,4,385,1105,1,397,1001,64,1,64,1002,64,2,64,109,-32,1208,10,34,63,1005,63,419,4,403,1001,64,1,64,1105,1,419,1002,64,2,64,109,30,2105,1,0,4,425,1106,0,437,1001,64,1,64,1002,64,2,64,109,-28,1207,6,21,63,1005,63,455,4,443,1106,0,459,1001,64,1,64,1002,64,2,64,109,4,2101,0,8,63,1008,63,31,63,1005,63,485,4,465,1001,64,1,64,1105,1,485,1002,64,2,64,109,5,1207,-4,28,63,1005,63,505,1001,64,1,64,1106,0,507,4,491,1002,64,2,64,109,9,21102,41,1,2,1008,1016,39,63,1005,63,531,1001,64,1,64,1106,0,533,4,513,1002,64,2,64,109,-10,1201,4,0,63,1008,63,30,63,1005,63,553,1106,0,559,4,539,1001,64,1,64,1002,64,2,64,109,19,21108,42,41,-4,1005,1019,579,1001,64,1,64,1106,0,581,4,565,1002,64,2,64,109,-26,1201,3,0,63,1008,63,32,63,1005,63,607,4,587,1001,64,1,64,1106,0,607,1002,64,2,64,109,20,1205,3,623,1001,64,1,64,1105,1,625,4,613,1002,64,2,64,109,2,21107,43,42,-1,1005,1018,645,1001,64,1,64,1106,0,647,4,631,1002,64,2,64,109,-11,2102,1,1,63,1008,63,29,63,1005,63,667,1105,1,673,4,653,1001,64,1,64,1002,64,2,64,109,27,2106,0,-8,1001,64,1,64,1105,1,691,4,679,1002,64,2,64,109,-25,2107,25,-4,63,1005,63,713,4,697,1001,64,1,64,1105,1,713,1002,64,2,64,109,-2,21108,44,44,2,1005,1010,735,4,719,1001,64,1,64,1106,0,735,1002,64,2,64,109,11,21101,45,0,-3,1008,1016,45,63,1005,63,757,4,741,1106,0,761,1001,64,1,64,1002,64,2,64,109,-15,1202,3,1,63,1008,63,22,63,1005,63,781,1105,1,787,4,767,1001,64,1,64,1002,64,2,64,109,6,21101,46,0,0,1008,1010,49,63,1005,63,811,1001,64,1,64,1105,1,813,4,793,1002,64,2,64,109,-7,2108,34,1,63,1005,63,835,4,819,1001,64,1,64,1105,1,835,1002,64,2,64,109,15,2106,0,10,4,841,1001,64,1,64,1106,0,853,1002,64,2,64,109,-25,2107,33,7,63,1005,63,873,1001,64,1,64,1106,0,875,4,859,1002,64,2,64,109,7,21102,47,1,10,1008,1010,47,63,1005,63,897,4,881,1105,1,901,1001,64,1,64,4,64,99,21102,1,27,1,21102,915,1,0,1105,1,922,21201,1,12038,1,204,1,99,109,3,1207,-2,3,63,1005,63,964,21201,-2,-1,1,21102,942,1,0,1105,1,922,21202,1,1,-1,21201,-2,-3,1,21101,0,957,0,1106,0,922,22201,1,-1,-2,1106,0,968,22101,0,-2,-2,109,-3,2105,1,0"
  2.  
  3. list3 = thing.split(",")
  4. for i in range(10000):
  5.     list3.append(0)
  6. adv = 1
  7.  
  8.  
  9. class MyIter:
  10.     def __init__(self, start, stop):
  11.         self.start = start
  12.         self.stop = stop
  13.  
  14.     def __iter__(self):
  15.         self.cur = self.start
  16.         while self.cur < self.stop:
  17.             yield self.cur
  18.             self.cur += 1
  19.  
  20.  
  21. def find_thing():
  22.     global adv
  23.     list2 = {}
  24.     relbase = 0
  25.     for i in range(0, len(list3)):
  26.         list2[int(i)] = int(list3[i])
  27.  
  28.     m = MyIter(0, len(list2))
  29.     for t in m:
  30.     #for t in range(0, len(list2), adv):
  31.         opcode = str(list2[t])[-2:]
  32.         if len(str(list2[t])) > 2:
  33.             mod = str(list2[t])[:-2]
  34.         else:
  35.             mod = ""
  36.         modes = []
  37.         for i in range(3-len(mod)):
  38.             modes.append(0)
  39.         for char in mod:
  40.             modes.append(int(char))
  41.         modes.reverse()
  42.  
  43.         print("Opcode: " + opcode)
  44.         print(modes)
  45.  
  46.         if opcode == "99":
  47.             break
  48.  
  49.         if modes[0] == 0:
  50.             x = list2[t+1]
  51.         elif modes[0] == 1:
  52.             x = t+1
  53.         else:
  54.             x = list2[t+1]+relbase
  55.  
  56.         if modes[1] == 0:
  57.             y = list2[t+2]
  58.         elif modes[1] == 1:
  59.             y = t+2
  60.         else:
  61.             y = list2[t+2]+relbase
  62.  
  63.         if modes[2] == 0:
  64.             z = list2[t+3]
  65.         elif modes[2] == 1:
  66.             z = t+3
  67.         else:
  68.             z = list2[t+3]+relbase
  69.  
  70.         if opcode == "01" or opcode == "1":
  71.             list2[z] = list2[x]+list2[y]
  72.             m.cur += 3
  73.         elif opcode == "02" or opcode == "2":
  74.             list2[z] = list2[x]*list2[y]
  75.             m.cur += 3
  76.         elif opcode == "03" or opcode == "3":
  77.             print("INPUT!")
  78.             inp = input("Input: ")
  79.             list2[x] = int(inp)
  80.             m.cur += 1
  81.         elif opcode == "04" or opcode == "4":
  82.             print("OUTPUT!")
  83.             print("Out: " + str(list2[x]))
  84.             m.cur += 1
  85.  
  86.         elif opcode == "05" or opcode == "5":
  87.             if list2[x] != 0:
  88.                 m.cur = list2[y]-1
  89.             else:
  90.                 m.cur += 2
  91.         elif opcode == "06" or opcode == "6":
  92.             if list2[x] == 0:
  93.                 m.cur = list2[y]-1
  94.             else:
  95.                 m.cur += 2
  96.         elif opcode == "07" or opcode == "7":
  97.             if list2[x] < list2[y]:
  98.                 list2[z] = 1
  99.             else:
  100.                 list2[z] = 0
  101.             m.cur += 3
  102.         elif opcode == "08" or opcode == "8":
  103.             if list2[x] == list2[y]:
  104.                 list2[z] = 1
  105.             else:
  106.                 list2[z] = 0
  107.             m.cur += 3
  108.         elif opcode == "09" or opcode == "9":
  109.             relbase += list2[x]
  110.             print("relbase" + str(relbase))
  111.             m.cur += 1
  112.         else:
  113.             break
  114.  
  115.     return list(list2.values())
  116.  
  117.  
  118. print(find_thing())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement