Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # computer = [3,0,4,0,3,0,4,0,99]
- # computer = [1101,100,-1,4,0]
- computer = [3,225,1,225,6,6,1100,1,238,225,104,0,1101,86,8,225,1101,82,69,225,101,36,65,224,1001,224,-106,224,4,224,1002,223,8,223,1001,224,5,224,1,223,224,223,102,52,148,224,101,-1144,224,224,4,224,1002,223,8,223,101,1,224,224,1,224,223,223,1102,70,45,225,1002,143,48,224,1001,224,-1344,224,4,224,102,8,223,223,101,7,224,224,1,223,224,223,1101,69,75,225,1001,18,85,224,1001,224,-154,224,4,224,102,8,223,223,101,2,224,224,1,224,223,223,1101,15,59,225,1102,67,42,224,101,-2814,224,224,4,224,1002,223,8,223,101,3,224,224,1,223,224,223,1101,28,63,225,1101,45,22,225,1101,90,16,225,2,152,92,224,1001,224,-1200,224,4,224,102,8,223,223,101,7,224,224,1,223,224,223,1101,45,28,224,1001,224,-73,224,4,224,1002,223,8,223,101,7,224,224,1,224,223,223,1,14,118,224,101,-67,224,224,4,224,1002,223,8,223,1001,224,2,224,1,223,224,223,4,223,99,0,0,0,677,0,0,0,0,0,0,0,0,0,0,0,1105,0,99999,1105,227,247,1105,1,99999,1005,227,99999,1005,0,256,1105,1,99999,1106,227,99999,1106,0,265,1105,1,99999,1006,0,99999,1006,227,274,1105,1,99999,1105,1,280,1105,1,99999,1,225,225,225,1101,294,0,0,105,1,0,1105,1,99999,1106,0,300,1105,1,99999,1,225,225,225,1101,314,0,0,106,0,0,1105,1,99999,7,677,677,224,102,2,223,223,1005,224,329,1001,223,1,223,1008,226,226,224,1002,223,2,223,1005,224,344,1001,223,1,223,1107,677,226,224,1002,223,2,223,1006,224,359,1001,223,1,223,107,677,677,224,102,2,223,223,1005,224,374,101,1,223,223,1108,677,226,224,102,2,223,223,1005,224,389,1001,223,1,223,1007,677,677,224,1002,223,2,223,1005,224,404,101,1,223,223,1008,677,226,224,102,2,223,223,1005,224,419,101,1,223,223,1108,226,677,224,102,2,223,223,1006,224,434,1001,223,1,223,8,677,226,224,1002,223,2,223,1005,224,449,101,1,223,223,1008,677,677,224,1002,223,2,223,1006,224,464,1001,223,1,223,1108,226,226,224,1002,223,2,223,1005,224,479,1001,223,1,223,1007,226,677,224,102,2,223,223,1005,224,494,1001,223,1,223,1007,226,226,224,102,2,223,223,1005,224,509,101,1,223,223,107,677,226,224,1002,223,2,223,1006,224,524,1001,223,1,223,108,677,677,224,102,2,223,223,1006,224,539,101,1,223,223,7,677,226,224,102,2,223,223,1006,224,554,1001,223,1,223,1107,226,677,224,102,2,223,223,1005,224,569,101,1,223,223,108,677,226,224,1002,223,2,223,1006,224,584,101,1,223,223,108,226,226,224,102,2,223,223,1006,224,599,1001,223,1,223,1107,226,226,224,102,2,223,223,1006,224,614,1001,223,1,223,8,226,677,224,102,2,223,223,1006,224,629,1001,223,1,223,107,226,226,224,102,2,223,223,1005,224,644,101,1,223,223,8,226,226,224,102,2,223,223,1006,224,659,101,1,223,223,7,226,677,224,102,2,223,223,1005,224,674,101,1,223,223,4,223,99,226]
- # computer = [1,12,2,3,1,1,2,3,1,3,4,3,1,5,0,3,2,13,1,19,1,10,19,23,1,23,9,27,1,5,27,31,2,31,13,35,1,35,5,39,1,39,5,43,2,13,43,47,2,47,10,51,1,51,6,55,2,55,9,59,1,59,5,63,1,63,13,67,2,67,6,71,1,71,5,75,1,75,5,79,1,79,9,83,1,10,83,87,1,87,10,91,1,91,9,95,1,10,95,99,1,10,99,103,2,103,10,107,1,107,9,111,2,6,111,115,1,5,115,119,2,119,13,123,1,6,123,127,2,9,127,131,1,131,5,135,1,135,13,139,1,139,10,143,1,2,143,147,1,147,10,0,99,2,0,14,0]
- # computer = [1002,4,3,4,33]
- # i mean ... it sort of works, it produces 3 as the first output for some reason ...
- current_index = 0
- while(current_index < len(computer) ):
- # print(current_index)
- if(computer[current_index] == 1):
- computer[computer[current_index + 3]] = computer[computer[current_index + 1]] + computer[computer[current_index + 2]]
- current_index += 4
- elif(computer[current_index] == 2):
- computer[computer[current_index + 3]] = computer[computer[current_index + 1]] * computer[computer[current_index + 2]]
- current_index += 4
- elif (computer[current_index] == 3):
- computer[computer[current_index + 1]] = int(input("input: "))
- current_index += 2
- elif (computer[current_index] == 4):
- print("output: ", computer[computer[current_index + 1]])
- current_index += 2
- elif (computer[current_index] == 99):
- break
- else:
- # be careful of comparing chars with ints
- opcode = str(computer[current_index])
- if(len(opcode) < 4): opcode = "0" + opcode
- op = int(opcode[len(opcode) - 1])
- # THREE DIGIT MINIMUM
- if(op != 4 and op != 3):
- # third parameter always in position mode
- parameter_1_value = computer[current_index + 1] if opcode[1] == '1' else computer[computer[current_index + 1]]
- # 4 HAS ONLY 1 PARAMETER
- parameter_2_value = computer[current_index + 2] if opcode[0] == '1' else computer[computer[current_index + 2]] # calls computer[1101] WHY?
- else:
- parameter_1_value = computer[current_index + 1] if opcode[1] == '1' else computer[computer[current_index + 1]]
- output_index = computer[current_index + 3]
- # 104 is interpreted as 0104 with a leading 0 <<<<<< IMPORTANT
- if(op == 1):
- computer[output_index] = parameter_1_value + parameter_2_value
- # print(parameter_1_value)
- current_index += 4
- elif(op == 2):
- computer[output_index] = parameter_1_value * parameter_2_value
- current_index += 4
- elif(op == 3):
- computer[computer[current_index + 1]] = int(input("input: "))
- current_index += 2
- elif(op == 4):
- # print(computer)
- print("output: ", computer[computer[current_index + 1]])
- current_index += 2
- # print(computer) # 104 not a command thats why its getting stuck but how?
- # if(current_index > 9):
- # break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement