As a part of this Kata, you need to create a function that when provided with a triplet, returns the index of the numerical element that lies between the other two elements.

The input to the function will be an array of three distinct numbers (Haskell: a tuple).

For example:

    gimme([2, 3, 1]) => 0

*2* is the number that fits between *1* and *3* and the index of *2* in the input array is *0*.

Another example (just to make sure it is clear):

    gimme([5, 10, 14]) => 1
    
*10* is the number that fits between *5* and *14* and the index of *10* in the input array is *1*.

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Data structures

Starter code: def gimme(input_array):
	

Solutions:
def gimme(inputArray):
	return inputArray.index(sorted(inputArray)[1])


def gimme(input_array):
	return input_array.index(sorted(input_array)[1])


gimme = lambda l: l.index(sorted(l)[1])


def gimme(lst):
	return lst.index(sorted(lst)[len(lst) // 2])


def gimme(arr):
	return len(arr) - arr.index(max(arr)) - arr.index(min(arr))


def gimme(arr):
	return arr.index(sorted(arr)[1])


def gimme(input):
	s = sorted(input)
	return input.index(s[1])


import copy

def gimme(input_array):
	input_array_sorted = copy.deepcopy(input_array)
	input_array_sorted.sort()
	middle = input_array_sorted[int(len(input_array_sorted) / 2)]
	return input_array.index(middle)


def gimme(a):
	return a.index(sorted(a)[1])


gimme = lambda a: a.index(sorted(a)[1])


def gimme(triplet):
	return triplet.index(sorted(triplet)[1])


def gimme(arr):
	arr1 = sorted(arr)
	middle = arr1[1]
	return arr.index(middle)


def gimme(input_array):
	a = input_array.copy()
	a.sort()
	b = a[1]
	return input_array.index(b)


def gimme(input_array):
	for e in input_array:
		i = 0
		for p in range(len(input_array)):
			if e > input_array[p]:
				i += 1
			if e < input_array[p]:
				i -= 1
		if i == 0:
			for ele in range(len(input_array)):
				if e == input_array[ele]:
					return ele


def gimme(l):
	return [x for x in range(len(l)) if x not in [l.index(min(l)), l.index(max(l))]][0]


def gimme(input_array):
	return 3 - input_array.index(max(input_array)) - input_array.index(min(input_array))


def gimme(i):
	for x in i:
		if x != max(i) and x != min(i):
			return i.index(x)


def gimme(input_array):
	a = []
	b = sum(input_array) / len(input_array)
	for i in input_array:
		a.append(abs(b - i))
	return a.index(min(a))


def gimme(a):
	for x in a:
		if max(a) > x > min(a):
			return a.index(x)


def gimme(array):
	for i in range(2):
		if (array[i] < array[i - 1]) != (array[i] < array[i + 1]):
			return i
	return 2


def gimme(inputArray):
	return 3 - inputArray.index(min(inputArray)) - inputArray.index(max(inputArray))


def gimme(input_array):
	get = input_array.__getitem__
	return 3 - min(list(range(3)), key=get) - max(list(range(3)), key=get)


def gimme(input_array):
	(a, b, c) = input_array
	return 2 if a < c < b or a > c > b else a < b < c or a > b > c


def gimme(a):
	return [a.index(b) for b in a if b != max(a) and b != min(a)][0]


def gimme(input_array):
	if input_array[2] > input_array[0] and input_array[2] > input_array[1]:
		if input_array[0] > input_array[1]:
			return 0
		else:
			return 1
	elif input_array[0] > input_array[1] and input_array[0] > input_array[2]:
		if input_array[1] > input_array[2]:
			return 1
		else:
			return 2
	elif input_array[2] > input_array[0]:
		return 2
	else:
		return 0


def gimme(input_array):
	for (i, c) in enumerate(input_array):
		if c == sorted(input_array)[1]:
			return i


from typing import List

def gimme(array: List[int]) -> int:
	return array.index(next(iter({*array} - {min(array), max(array)})))


def gimme(input_array):
	maxpos = input_array.index(max(input_array))
	minpos = input_array.index(min(input_array))
	for i in input_array:
		if input_array.index(i) != maxpos and input_array.index(i) != minpos:
			return input_array.index(i)


def gimme(input_array):
	middle_idx = len(input_array) // 2
	middle_value = sorted(input_array)[middle_idx]
	return input_array.index(middle_value)


def gimme(input_array):
	temp = input_array[:]
	temp.sort()
	middle_value = int(len(input_array)) // 2
	return input_array.index(temp[middle_value])


def gimme(input_array):
	minimum = min(input_array)
	maximum = max(input_array)
	for l in input_array:
		if l < maximum and l > minimum:
			return input_array.index(l)


def gimme(input_array):
	max_num = max(input_array)
	min_num = min(input_array)
	for elem in input_array:
		if elem != max_num and elem != min_num:
			return input_array.index(elem)


def gimme(b):
	a = max(b[0], b[1], b[2])
	c = min(b[0], b[1], b[2])
	for i in range(3):
		if b[i] != a and b[i] != c:
			return i


def gimme(input_array):
	min_no = min(input_array)
	max_no = max(input_array)
	for i in input_array:
		if i > min_no and i < max_no:
			return input_array.index(i)


def gimme(inp):
	a = max(inp)
	b = min(inp)
	for i in range(len(inp)):
		if b < inp[i] < a:
			return i


def gimme(input_array):
	mi = min(input_array)
	ma = max(input_array)
	for i in range(len(input_array)):
		if input_array[i] != mi and input_array[i] != ma:
			return i


from copy import copy

def gimme(input_array):
	g = copy(input_array)
	g.sort()
	return input_array.index(g[1])


def gimme(input_array):
	ord = sorted(input_array)[len(input_array) // 2]
	return input_array.index(ord)


def gimme(input_array):
	maximum = max(input_array)
	minimum = min(input_array)
	for i in input_array:
		if i != maximum and i != minimum:
			mean = input_array.index(i)
	return mean


def gimme(input_array):
	arr = sorted(input_array)
	middle = arr[1]
	return input_array.index(middle)


def gimme(array):
	v0 = array[0]
	v1 = array[1]
	v2 = array[2]
	array.sort()
	if array[1] == v0:
		return 0
	if array[1] == v1:
		return 1
	if array[1] == v2:
		return 2


def gimme(input_array):
	copy = sorted(list(input_array))
	return input_array.index(copy[1])


def gimme(a):
	for i in a:
		if i != max(a) and i != min(a):
			return a.index(i)


def gimme(input_array):
	for (pos, num) in enumerate(input_array):
		if num != min(input_array) and num != max(input_array):
			return pos


def gimme(input_array):
	d = {}
	for (i, v) in enumerate(input_array):
		d[i] = v
	x = sorted(list(d.items()), key=lambda x: x[1])
	return x[1][0]


def gimme(input_array):
	newarr = input_array.copy()
	[newarr.remove(x) for x in [max(input_array), min(input_array)]]
	return input_array.index(newarr[0])


def gimme(input_array):
	i = sorted(input_array)[len(input_array) // 2]
	return input_array.index(i)


def gimme(input_array):
	a = max(input_array)
	b = min(input_array)
	for i in input_array:
		if i == a or i == b:
			continue
		else:
			return input_array.index(i)


def gimme(input_array):
	orig = input_array[:]
	input_array.sort()
	middle = int((len(input_array) - 1) / 2)
	return orig.index(input_array[middle])


def gimme(input_array):
	for x in input_array:
		if x != min(input_array) and x != max(input_array):
			choosen = x
	return input_array.index(choosen)


def gimme(input_array):
	min_value = min(input_array)
	max_value = max(input_array)
	for (idx, val) in enumerate(input_array):
		if val == min_value:
			continue
		if val == max_value:
			continue
		return idx


def gimme(input_array):
	s = sorted(input_array)
	return input_array.index(s[len(s) // 2])


def gimme(arr):
	for (i, el) in enumerate(arr):
		if el != min(arr) and el != max(arr):
			return i


def gimme(input_array):
	print(input_array)
	middle = round(sum(input_array) - min(input_array) - max(input_array), 2)
	index = input_array.index(middle)
	return index


def gimme(input_array):
	srt = sorted(input_array)
	for i in range(3):
		if input_array[i] == srt[1]:
			return i


def gimme(input_array):
	a = sorted(input_array)
	return input_array.index(a[len(a) // 2])


def gimme(input_array):
	x = sorted(list(input_array))
	for y in range(len(input_array)):
		if x[1] == input_array[y]:
			return y


def gimme(input_array):
	i = 0
	while i < 3:
		c = input_array[i]
		if c < max(input_array) and c > min(input_array):
			return input_array.index(c)
			break
		else:
			i += 1


def gimme(array):
	first = array[0]
	second = array[1]
	third = array[2]
	if first <= second <= third:
		return 1
	elif first <= third <= second:
		return 2
	elif second <= first <= third:
		return 0
	elif second <= third <= first:
		return 2
	elif third <= first <= second:
		return 0
	elif third <= second <= first:
		return 1


def gimme(input_array):
	middle_num = sorted(input_array)[1]
	counter = 0
	for i in input_array:
		if i == middle_num:
			return counter
		else:
			counter += 1
gimme([2, 3, 1])


import numpy as np

def gimme(input_array):
	choices = set([0, 1, 2])
	not_it = set([np.argmin(input_array), np.argmax(input_array)])
	return list(choices - not_it)[0]


def gimme(input_array):
	minEl = min(input_array)
	maxEl = max(input_array)
	i = 0
	for el in input_array:
		if el < maxEl and el > minEl:
			return i
		i = i + 1


def gimme(input_array):
	sort = sorted(input_array)
	x = sort[1]
	for i in range(len(input_array)):
		if x == input_array[i]:
			return i


def gimme(input_array):
	sort = sorted(input_array)
	x = sort[1]
	leng = len(input_array)
	if sum(input_array) < 0:
		sort = reversed(sort)
	for i in range(leng):
		if x == input_array[i]:
			return i


def gimme(input_array):
	for i in input_array:
		if i < input_array[-1] and i > input_array[0]:
			return input_array.index(i)
		elif i < input_array[0] and i > input_array[-1]:
			return input_array.index(i)
		elif i < input_array[1] and i > input_array[0]:
			return input_array.index(i)
		elif i < input_array[0] and i > input_array[1]:
			return input_array.index(i)
		elif i < input_array[1] and i > input_array[-1]:
			return input_array.index(i)
		elif i < input_array[-1] and i > input_array[1]:
			return input_array.index(i)


def gimme(input_array):
	array = sorted(input_array)
	mid_num = array[int((len(array) - 1) / 2)]
	return input_array.index(mid_num)


def gimme(input_array):
	for number in input_array:
		if number != max(input_array) and number != min(input_array):
			answer = number
	return input_array.index(answer)


def gimme(input_array):
	sort_arr = sorted(input_array)
	middle = sort_arr[1]
	return input_array.index(middle)


def gimme(input_array):
	a = input_array.index(max(input_array))
	b = input_array.index(min(input_array))
	for i in [0, 1, 2]:
		if i not in [a, b]:
			return i
			break


def gimme(input_array):
	inp2 = input_array.copy()
	inp2.remove(max(inp2))
	inp2.remove(min(inp2))
	return input_array.index(inp2[0])


def gimme(input_array):
	mins = min(input_array)
	maxs = max(input_array)
	for i in input_array:
		if i < maxs and i > mins:
			return input_array.index(i)


def gimme(input_array):
	big = max(input_array)
	small = min(input_array)
	for num in input_array:
		if num > small and num < big:
			return input_array.index(num)


def gimme(input_array):
	return input_array.index(sorted(input_array)[int((len(input_array) - 1) / 2)])


def gimme(input_array):
	max_i = input_array.index(max(input_array))
	min_i = input_array.index(min(input_array))
	middle_i = [i for i in range(len(input_array)) if i not in [max_i, min_i]][0]
	return middle_i


def gimme(input_array):
	Max = max(input_array)
	Min = min(input_array)
	n = round(sum(input_array), 3)
	k = round(n - Max - Min, 3)
	return input_array.index(k)


def gimme(input_array):
	M = max(input_array)
	m = min(input_array)
	if input_array.index(M) == 2 and input_array.index(m) == 0:
		return 1
	if input_array.index(M) == 1 and input_array.index(m) == 0:
		return 2
	if input_array.index(M) == 1 and input_array.index(m) == 2:
		return 0
	if input_array.index(M) == 2 and input_array.index(m) == 1:
		return 0
	if input_array.index(M) == 0 and input_array.index(m) == 2:
		return 1
	if input_array.index(M) == 0 and input_array.index(m) == 1:
		return 2


def gimme(input_array):
	array = sorted(input_array)
	middle_el = array[1]
	return input_array.index(middle_el)


def gimme(input_array):
	for x in range(len(input_array)):
		if min(input_array) != input_array[x] and max(input_array) != input_array[x]:
			return x


def gimme(arr):
	list = [i for i in arr if i != max(arr) and i != min(arr)]
	return arr.index(list[0])


import numpy as np

def gimme(input_array):
	return input_array.index(np.setdiff1d(input_array, [max(input_array), min(input_array)]))


def gimme(input_array):
	sortedlst = []
	unsortedlst = []
	for i in input_array:
		unsortedlst.append(i)
		sortedlst.append(i)
	sortedlst.sort()
	biggestNumber = sortedlst[1]
	return unsortedlst.index(biggestNumber)


def gimme(input_array):
	sort_items = []
	for i in input_array:
		sort_items.append(i)
	sort_items.sort()
	y = 0
	for i in input_array:
		if i == sort_items[1]:
			av = y
			break
		y += 1
	return y


def gimme(input_array):
	return input_array.index(list(set(input_array) - {min(input_array)} - {max(input_array)})[0])


def gimme(input_array):
	data = [float(i) for i in sorted(input_array)]
	return input_array.index(data[1])


def gimme(i):
	if i[0] > i[1] and i[0] < i[2]:
		return 0
	elif i[0] > i[2] and i[0] < i[1]:
		return 0
	elif i[1] > i[0] and i[1] < i[2]:
		return 1
	elif i[1] > i[2] and i[1] < i[1]:
		return 1
	elif i[2] > i[1] and i[2] < i[0]:
		return 2
	elif i[2] > i[0] and i[2] < i[1]:
		return 2
	else:
		return 1


def gimme(input_array):
	a = list()
	print(a, input_array)
	x = 0
	for i in input_array:
		print('i:', i)
		a.append(i)
	input_array.sort()
	for i in a:
		if i == input_array[1]:
			break
		x += 1
	print(a, input_array)
	return x


def gimme(input_array):
	l2 = input_array.copy()
	l2.sort()
	mid_element = l2[1]
	index_mid_element = input_array.index(mid_element)
	return index_mid_element