Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from intcode_class import Intcode
- from itertools import permutations
- #get a two-dimentional array of all permutations of the numbers 5 through 9
- perms = list(permutations(range(5,10)))
- for i in range(len(perms)):
- perms[i] = list(perms[i])
- highOutput = 0
- highArray = []
- file1 = "input.txt"
- for x in perms:
- amp1 = Intcode("Amplifier 1", file1, x[0], 0)
- amp2 = Intcode("Amplifier 2", file1, x[1], 0)
- amp3 = Intcode("Amplifier 3", file1, x[2], 0)
- amp4 = Intcode("Amplifier 4", file1, x[3], 0)
- amp5 = Intcode("Amplifier 5", file1, x[4], 0)
- output = 0
- while(amp5.getCode() != 99):
- output = amp5.ampRun(amp4.ampRun(amp3.ampRun(amp2.ampRun(amp1.ampRun(output)))))
- if(output != None):
- if(output>highOutput):
- highOutput = output
- highArray = x
- print("The highest output permutation was " + str(highArray))
- print("with an output of " + str(highOutput))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement