-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinertial_checker.py
More file actions
37 lines (32 loc) · 1012 Bytes
/
Copy pathinertial_checker.py
File metadata and controls
37 lines (32 loc) · 1012 Bytes
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
def inertial_checker(arr):
odd_list = []
even_list = []
max_value = max(arr)
for number in arr:
if number % 2 == 0:
even_list.append(number)
else:
odd_list.append(number)
odd_list.sort()
even_list.sort()
if max_value % 2 != 0:
return 0
elif len(odd_list) < 1:
return 0
elif len(even_list) > 1:
for i in range(len(even_list) - 2, -1, -1):
if even_list[i] != max_value:
if odd_list[0] < even_list[i]:
return 0
else:
return 1
else:
return 1
else:
return 1
print(inertial_checker([1])) # output is 0
print(inertial_checker([2])) # output is 0
print(inertial_checker([1, 2, 3, 4])) # output is 0
print(inertial_checker([1, 1, 1, 1, 1, 1, 2])) # output is 1
print(inertial_checker([2, 12, 12, 4, 6, 8, 11])) # output is 1
print(inertial_checker([-2, -4, -6, -8, -11])) # output is 0