An array is defined to be `inertial`if the following conditions hold:
```
a. it contains at least one odd value  
b. the maximum value in the array is even 
c. every odd value is greater than every even value that is not the maximum value.
```
eg:-
```
So [11, 4, 20, 9, 2, 8] is inertial because 
a. it contains at least one odd value [11,9] 
b. the maximum value in the array is 20 which is even 
c. the two odd values (11 and 9) are greater than all the even values that are not equal to 20 (the maximum), i.e., [4, 2, 8]
```
Write a function called `is_inertial` that accepts an integer array and returns `true` if the array is inertial; otherwise it returns `false`.

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Data structures

Starter code: def is_inertial(arr):
	

Solutions:
def is_inertial(arr):
	mx = max(arr, default=1)
	miO = min((x for x in arr if x % 2 == 1), default=float('-inf'))
	miE2 = max((x for x in arr if x % 2 == 0 and x != mx), default=float('-inf'))
	return mx % 2 == 0 and miE2 < miO


def is_inertial(lst):
	odds = [n for n in lst if n % 2 == 1]
	evens = sorted((n for n in lst if n % 2 == 0))[-2:]
	return bool(odds) and max(lst) in evens and (not evens[:-1] or min(odds) > evens[-2])


def is_inertial(arr):
	(even, odd) = ([], [])
	for num in arr:
		if num % 2 == 0:
			even.append(num)
		else:
			odd.append(num)
	if len(odd) == 0 or max(even) != max(arr) or min(odd) < sorted(even)[-2]:
		return False
	else:
		return True


def is_inertial(arr):
	maxnr_odd = minnr_odd = maxnr_even = maxnr2nd_even = None
	for nr in arr:
		if nr % 2 == 0:
			if maxnr_even is None:
				maxnr_even = nr
			elif nr > maxnr_even:
				(maxnr_even, maxnr2nd_even) = (nr, maxnr_even)
			elif maxnr2nd_even is None or maxnr2nd_even < nr:
				maxnr2nd_even = nr
		else:
			if minnr_odd is None or minnr_odd > nr:
				minnr_odd = nr
			if maxnr_odd is None or maxnr_odd < nr:
				maxnr_odd = nr
	return maxnr_even is not None and maxnr_odd is not None and (minnr_odd is not None) and (maxnr_odd < maxnr_even) and (maxnr2nd_even is None or minnr_odd > maxnr2nd_even)


def is_inertial(array):
	if not array:
		return False
	max_value = max(array)
	if max_value % 2:
		return False
	try:
		return min((odd for odd in array if odd % 2)) > max((even for even in array if even < max_value and even % 2 == 0))
	except ValueError:
		return False


is_inertial = lambda a: a.sort() or (lambda e, o: e > [] < o and max(e[:-1] + [o[0] - 1]) < o[0] <= o[-1] < e[-1])(*[[n for n in a if n % 2 == m] for m in (0, 1)])


def is_inertial(a):
	try:
		return max(a) % 2 == 0 and min((e for e in a if e % 2)) > max((e for e in a if e % 2 == 0 and e < max(a)))
	except ValueError:
		return False


def is_inertial(arr):
	try:
		return sorted([z for z in arr if z % 2])[0] > sorted([x for x in arr if x % 2 == 0])[:-1][-1] and max(arr) % 2 == 0 and (not not [z for z in arr if z % 2]) if arr else False
	except IndexError:
		return False


def is_inertial(a):
	odd = {i for i in a if i % 2}
	even = set(a) - odd
	if not even:
		return False
	q = sorted(even)[-2] if len(even) > 1 else sorted(even)[0]
	return odd and max(even) > max(odd) and (min(odd) > q)


def is_inertial(arr):
	if not arr or len(arr) < 2:
		return False
	m1 = max(arr)
	(m2, m_odd) = (max(arr[1:], key=lambda x: (1 - x % 2 and x != m1, x)), min(arr, key=lambda x: (1 - x % 2, x)))
	return bool(m_odd % 2) and (not bool(m1 % 2)) and bool(m2 % 2 or m_odd > m2)