-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday2b.py
45 lines (38 loc) · 974 Bytes
/
day2b.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
#too lazy to make this simpler
file = open('input.txt', 'r')
x = file.readlines()
total = 0
for i in x:
i = i.strip()
i = i.split(' ')
i = list(map(int, i))
tota = 0
up = 0
down = 0
for j in range(0, len(i) - 1, 1):
a = int(i[j])
b = int(i[j+1])
if(a > b):
if(a - b < 4):
down += 1
if(a < b):
if(b - a < 4):
up += 1
if ((len(i) - 1) == up or (len(i) - 1) == down):
tota += 1
for q in range(len(i)):
if q > 0:
i.insert(q-1, x)
x = i.pop(q)
up = sorted(i)
down = sorted(i, reverse=True)
if (i == up or i == down):
tot = 0
for p in range(len(i) - 1):
if(up[p + 1] - up[p] < 4 and up[p + 1] - up[p] > 0):
tot += 1
if(tot == len(i) - 1):
tota += 1
if(tota > 0):
total += 1
print(total)