add solution 9, parts 1 and 2
This commit is contained in:
parent
34d996c2c1
commit
baa82e4fa0
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
fd = open('input', 'r')
|
||||
lines = [int(i.rstrip()) for i in fd.readlines()]
|
||||
|
||||
data = [int(i) for i in lines[0:24]]
|
||||
found = 0
|
||||
cnt = 0
|
||||
while True:
|
||||
num = int(lines[25 + cnt])
|
||||
|
||||
iicount = 0
|
||||
for i in data:
|
||||
for j in data:
|
||||
if i + j == num: iicount += 1
|
||||
if iicount == 0:
|
||||
print(num)
|
||||
found = num * 10
|
||||
break
|
||||
|
||||
data.append(num)
|
||||
cnt += 1
|
||||
|
||||
found = int(found / 10)
|
||||
index = lines.index(found)
|
||||
|
||||
relevant = lines[0:index]
|
||||
|
||||
for i in range(len(relevant)):
|
||||
added = []
|
||||
tot = 0
|
||||
elem = i
|
||||
try:
|
||||
while tot != found:
|
||||
tot += relevant[elem]
|
||||
added.append(relevant[elem])
|
||||
elem += 1
|
||||
added.sort()
|
||||
print(added[0] + added[-1])
|
||||
except:
|
||||
pass
|
||||
|
Loading…
Reference in New Issue