2021-01-04 13:07:46 +03:00
|
|
|
from fileio import open
|
|
|
|
let f = open('test/day1.in','r')
|
2022-06-29 08:55:46 +03:00
|
|
|
let lines = [int(x) for x in f.readlines()]
|
2021-01-04 13:07:46 +03:00
|
|
|
f.close()
|
|
|
|
|
|
|
|
# Make a bad set
|
2021-02-05 10:09:29 +03:00
|
|
|
let data = set(lines)
|
2021-01-04 13:07:46 +03:00
|
|
|
|
|
|
|
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
|
|
|
|