-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodeAdvent_9.py
111 lines (71 loc) · 1.8 KB
/
codeAdvent_9.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
'''
Created on 30 july 2021
@author: Antonio Martínez Fernández
'''
array = []
lista = []
def lectura():
archivo = open("input8.txt")
while True:
linea = archivo.readline()
if not linea:
break
array.append(int(linea))
def comprobar_suma(n):
k1 = 0
k2 = 0
for i in lista:
for j in lista:
if i+j == n and k1 != k2:
return True
k2 += 1
k2 = 0
k1 += 1
return False
def main_function():
i = 0
for n in array:
if(i >= 25):
if(comprobar_suma(array[i]) == False):
print(array[i])
return(array[i])
lista.append(array[i])
lista.pop(0)
i += 1
else:
lista.append(array[i])
i += 1
def clasificar_solucion():
global lista
menor = 999999999999999999999
mayor = 0
for actual in lista:
if(actual < menor):
menor = actual
if(actual > mayor):
mayor = actual
return menor, mayor
def sumatorio():
global lista
total = 0
for actual in lista:
total += actual
return total
def main_function_v2(n):
global lista
for i in range(0, len(array)-1, 1):
lista.append(array[i])
for j in range(i+1, len(array)-1, 1):
lista.append(array[j])
if(sumatorio() == n):
print(clasificar_solucion())
return 0
elif(sumatorio() > n):
lista = []
break
if __name__ == '__main__':
lectura()
aux = main_function()
lista = []
print()
main_function_v2(aux)