Browse Source

Add day 9

master
mid-kid 4 years ago
parent
commit
ae8a2eb85a
  1. 32
      d09.py
  2. 1000
      d09_input.txt
  3. 2
      d09_output.txt

32
d09.py

@ -0,0 +1,32 @@
#!/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

1000
d09_input.txt

File diff suppressed because it is too large

2
d09_output.txt

@ -0,0 +1,2 @@
1930745883
268878261
Loading…
Cancel
Save