initial commit on day 9

This commit is contained in:
Juan José Gutiérrez de Quevedo Pérez 2020-12-09 09:26:04 +01:00
commit f896e7c753
31 changed files with 8328 additions and 0 deletions

15
9/1.py Normal file
View file

@ -0,0 +1,15 @@
def find_sum(l, total):
for i in l:
m = list(filter(lambda x: i!=x and i + x == total, l))
if m:
return True
return False
with open("input") as f:
content = [int(x.strip()) for x in f]
r = 25
for i in range(r, len(content)):
if not find_sum(content[i-r:i], content[i]):
print(content[i])
break

12
9/2.py Normal file
View file

@ -0,0 +1,12 @@
with open("input") as f:
content = [int(x.strip()) for x in f]
target = 22406676
for i in range(len(content)):
for length in range(2, len(content) - i):
subset = content[i:i+length]
s = sum(subset)
if s == target:
print(min(subset) + max(subset))
if s > target:
break

20
9/einput Normal file
View file

@ -0,0 +1,20 @@
35
20
15
25
47
40
62
55
65
95
102
117
150
182
127
219
299
277
309
576

1000
9/input Normal file

File diff suppressed because it is too large Load diff