Advertisement
Musical_Muze

Day 7, Part 1

Dec 10th, 2019
553
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. from ampIntcode import intcode
  2. from itertools import permutations
  3.  
  4. #get a two-dimentional array of all permutations of the numbers 1 through 4
  5. perms = list(permutations(range(0,5)))
  6. for i in range(len(perms)):
  7.     perms[i] = list(perms[i])
  8.  
  9. highOutput = 0
  10. highArray = []
  11. file1 = "input.txt"
  12.  
  13. for x in perms:
  14.     output = intcode(file1,x[4],intcode(file1,x[3],intcode(file1,x[2],intcode(file1,x[1],intcode(file1,x[0],0)))))
  15.     if(output>highOutput):
  16.         highOutput = output
  17.         highArray = x
  18.  
  19. print("The highest output permutation was " + str(highArray))
  20. print("with an output of " + str(highOutput))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement