kuroko/test/day1.krk

26 lines
615 B
Python
Raw Normal View History

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.readlines()]
2021-01-04 13:07:46 +03:00
f.close()
# Make a bad set
let data = set(lines)
2021-01-04 13:07:46 +03:00
for line in lines:
if (2020 - line) in data:
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:
print(((s - lines[ind]) * lines[ind]) * (2020 -s))
2021-01-04 13:07:46 +03:00