JakeTheSnake003

AOC2020 Day 1

Dec 1st, 2020
503
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import time
  2. start_time = time.time()
  3.  
  4. numbers_file = open("input.txt", "r").read()
  5. numbers = numbers_file.split("\n")[:-1]
  6. for number in enumerate(numbers):
  7.     numbers[number[0]] = int(number[1])
  8. numbers = sorted(numbers)
  9.  
  10. for number in enumerate(numbers):
  11.     if number[1] >= 1010:
  12.         sub_numbers = numbers[:number[0]]
  13.         sur_numbers = numbers[number[0]:]
  14.         break
  15.  
  16. for sub in sub_numbers:
  17.     for sur in sur_numbers:
  18.         if sub + sur == 2020:
  19.             answer = sub*sur
  20.  
  21. print('Answer:', answer)
  22. print('Executed in:', round((time.time() - start_time) * 1000, 2), 'milliseconds')
  23.  
RAW Paste Data