-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path9-2.py
58 lines (55 loc) · 1.26 KB
/
9-2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
f = open("Day9Pre.txt", "r")
d = f.read().split("\n")
place = 0
array = list()
pre = 25
for i in range(pre):
array.append(d[place])
place = place + 1
while True:
if place >= len(d):
break
fail = 1
for x in range(len(array)):
for y in range(len(array)):
if x == y:
continue
#print("Total: " + str(int(array[x]) + int(array[y])))
if int(array[x]) + int(array[y]) == int(d[place]):
fail = 0
if fail:
break
array.append(d[place])
array.pop(0)
place = place + 1
print(d[place])
number = int(d[place])
place = 0
done = 0
while True:
if place >= len(d):
break
place2 = int(place)
lowest = int(d[place2])
counting = 0
highest = 0
lowest = 1000000000
while True:
if place2 >= len(d):
break
counting = counting + int(d[place2])
if int(d[place2]) < lowest:
lowest = int(d[place2])
if int(int(d[place2]) > highest):
highest = int(d[place2])
if counting > number:
break
if counting == number:
done = 1
break
place2 = place2 + 1
place = place + 1
if done:
break
print()
print(lowest + highest)