Advertisement
rolfvanoven

aoc 2019 dag 2

Sep 5th, 2022
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.61 KB | None | 0 0
  1. oercomp = [1,12,2,3,1,1,2,3,1,3,4,3,1,5,0,3,2,13,1,19,1,6,19,23,2,6,23,27,1,5,27,31,2,31,9,35,1,35,5,39,1,39,5,43,1,43,10,47,2,6,47,51,1,51,5,55,2,55,6,59,1,5,59,63,2,63,6,67,1,5,67,71,1,71,6,75,2,75,10,79,1,79,5,83,2,83,6,87,1,87,5,91,2,9,91,95,1,95,6,99,2,9,99,103,2,9,103,107,1,5,107,111,1,111,5,115,1,115,13,119,1,13,119,123,2,6,123,127,1,5,127,131,1,9,131,135,1,135,9,139,2,139,6,143,1,143,5,147,2,147,6,151,1,5,151,155,2,6,155,159,1,159,2,163,1,9,163,0,99,2,0,14,0]
  2.  
  3.  
  4. comp = [1,12,2,3,1,1,2,3,1,3,4,3,1,5,0,3,2,13,1,19,1,6,19,23,2,6,23,27,1,5,27,31,2,31,9,35,1,35,5,39,1,39,5,43,1,43,10,47,2,6,47,51,1,51,5,55,2,55,6,59,1,5,59,63,2,63,6,67,1,5,67,71,1,71,6,75,2,75,10,79,1,79,5,83,2,83,6,87,1,87,5,91,2,9,91,95,1,95,6,99,2,9,99,103,2,9,103,107,1,5,107,111,1,111,5,115,1,115,13,119,1,13,119,123,2,6,123,127,1,5,127,131,1,9,131,135,1,135,9,139,2,139,6,143,1,143,5,147,2,147,6,151,1,5,151,155,2,6,155,159,1,159,2,163,1,9,163,0,99,2,0,14,0]
  5.  
  6.  
  7. def bereken(noun,verb):
  8.   stap = 0
  9.   klaar = 0
  10.   for x in range(len(comp)):
  11.     comp[x] = oercomp[x]
  12.   comp[1] = noun
  13.   comp[2] = verb
  14.   while klaar == 0:
  15.     if comp[stap*4] == 1:
  16.       comp[comp[(stap*4) + 3]] = comp[comp[(stap*4)+1]] + comp[comp[(stap*4)+2]]
  17.     if comp[stap*4] == 2:
  18.       comp[comp[(stap*4) + 3]] = comp[comp[(stap*4)+1]] * comp[comp[(stap*4)+2]]
  19.     if comp[stap*4] == 99:
  20.       klaar = 1
  21.     stap += 1
  22.   return(comp[0])
  23.  
  24.  
  25.  
  26.  
  27. #comp = [1,1,1,4,99,5,6,0,99]
  28. #comp = [1,9,10,3,2,3,11,0,99,30,40,50]
  29.  
  30.  
  31. for x in range(100):
  32.   for y in range(100):
  33.     if bereken(x,y) == 19690720:
  34.       print('gevonden! noun is', x, 'verb is', y)
  35.  
  36.  
  37.  
  38.  
  39.  
  40. #print(comp[0])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement