Guest User

Untitled

a guest
Dec 15th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. firewall = {}
  2.  
  3. with open('Day13_input') as f:
  4. for l in f.readlines():
  5. l = l.replace(':','').split()
  6. firewall[int(l[0])] = int(l[1])
  7.  
  8. #1
  9.  
  10. score = 0
  11.  
  12. for i in range(0,max(firewall)+1):
  13. if i in firewall and i%((firewall[i]*2)-2)==0:
  14. score += i*firewall[i]
  15.  
  16. print(score)
  17.  
  18. #2
  19.  
  20. delay = 0
  21. caught = True
  22. while(caught):
  23. caught = False
  24. delay+=1
  25. for i in range(0,max(firewall)+1):
  26. if i in firewall and (i+delay)%((firewall[i]*2)-2)==0:
  27. caught = True
  28. break
  29.  
  30. print(delay)
Add Comment
Please, Sign In to add comment