import time
infile = open('advent_2020_01_input.txt','r')
perm_storage = []
t0 = time.perf_counter()
# Part 1
for x in infile:
perm_storage.append(int(x))
nums = perm_storage.copy()
while nums:
for num1 in nums:
if (num1+nums[0] == 2020):
print(num1*nums[0])
nums.pop(0)
print('Time: {}'.format(time.perf_counter()-t0))
t0 = time.perf_counter()
# Part 2
nums = perm_storage.copy()
while nums:
nums2 = nums.copy()
while nums2:
for num in nums2:
if (num+nums[0]+nums2[0] == 2020):
print(num*nums[0]*nums2[0])
nums2.pop(0)
nums.pop(0)
print('Time: {}'.format(time.perf_counter()-t0))
t0 = time.perf_counter()
print("Old Way")
infile_x = open('advent_2020_01_input.txt','r')
# Part 1
for x in infile_x:
infile_y = open('advent_2020_01_input.txt','r')
for y in infile_y:
if (int(x)+int(y) == 2020):
print(int(x)*int(y))
print('Time: {}'.format(time.perf_counter()-t0))
t0 = time.perf_counter()
infile_x = open('advent_2020_01_input.txt','r')
# Part 2
for x in infile_x:
infile_y = open('advent_2020_01_input.txt','r')
for y in infile_y:
infile_z = open('advent_2020_01_input.txt','r')
for z in infile_z:
if (int(x)+int(y)+int(z) == 2020):
print(int(x)*int(y)*int(z))
print('Time: {}'.format(time.perf_counter()-t0))
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}