2021-01-04 13:07:46 +03:00
|
|
|
from fileio import open
|
|
|
|
let f = open('test/day1.in','r')
|
|
|
|
let lines = [int(x) for x in f.read().split("\n")][:-1] # because that split included a blank
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
# Make a bad set
|
|
|
|
let data = {}
|
|
|
|
for l in lines:
|
|
|
|
data[l] = 1
|
|
|
|
|
|
|
|
for line in lines:
|
|
|
|
if (2020 - line) in data:
|
2021-01-04 17:33:43 +03:00
|
|
|
print(line, 2020 - line, line * (2020 - line))
|
2021-01-04 13:07:46 +03:00
|
|
|
|
|
|
|
def sums_index(lines, ind):
|
|
|
|
let out = []
|
|
|
|
for line in lines[:ind]:
|
|
|
|
out.append(line + lines[ind])
|
|
|
|
for line in lines[ind:]:
|
|
|
|
out.append(line + lines[ind])
|
|
|
|
return out
|
|
|
|
|
|
|
|
for ind in range(len(lines)):
|
|
|
|
for s in sums_index(lines, ind):
|
|
|
|
if (2020 - s) in lines:
|
2021-01-04 17:33:43 +03:00
|
|
|
print(((s - lines[ind]) * lines[ind]) * (2020 -s))
|
2021-01-04 13:07:46 +03:00
|
|
|
|