Advent of Code 2020, now in the most terse and awful python possible
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

32 lines
669 B

#!/usr/bin/env python3
from sys import argv
i = [int(x.strip()) for x in open(argv[1])]
pre = 25
if len(argv) > 2:
pre = int(argv[2])
for x in range(pre, len(i)):
n = i[x]
for y in i[x-pre:x]:
if n-y in i[x-pre:x]:
break
else:
print(n)
for y in range(len(i)):
p = y
c = 0
while p < len(i):
c += i[p]
if c == n:
r = i[y:p+1]
print(min(r)+max(r))
break
if c > n:
break
p += 1
if c == n:
break
break