We define the "unfairness" of a list/array as the *minimal* difference between max(x1,x2,...xk) and min(x1,x2,...xk), for all possible combinations of k elements you can take from the list/array; both minimum and maximum of an empty list/array are considered to be 0.

**More info and constraints:**

* lists/arrays can contain values repeated more than once, plus there are usually more combinations that generate the required minimum;
* the list/array's length can be any value from 0 to 10^(6);
* the value of k will range from 0 to the length of the list/array,
* the minimum unfairness of an array/list with less than 2 elements is 0.

For example:

```python
min_unfairness([30,100,1000,150,60,250,10,120,20],3)==20 #from max(30,10,20)-min(30,10,20)==20, minimum unfairness in this sample
min_unfairness([30,100,1000,150,60,250,10,120,20],5)==90 #from max(30,100,60,10,20)-min(30,100,60,10,20)==90, minimum unfairness in this sample
min_unfairness([1,1,1,1,1,1,1,1,1,2,2,2,2,2,2],10)==1 #from max(1,1,1,1,1,1,1,1,1,2)-min(1,1,1,1,1,1,1,1,1,2)==1, minimum unfairness in this sample
min_unfairness([1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],10)==0 #from max(1,1,1,1,1,1,1,1,1,1)-min(1,1,1,1,1,1,1,1,1,1)==0, minimum unfairness in this sample
min_unfairness([1,1,-1],2)==0 #from max(1,1)-min(1,1)==0, minimum unfairness in this sample
```

**Note:** shamelessly taken from [here](https://www.hackerrank.com/challenges/angry-children), where it was created and debatably categorized and ranked.

Source: codewars | Difficulty: EASY

Starter code: def min_unfairness(arr,k):
	

Solutions:
def min_unfairness(arr, k):
	arr = sorted(arr)
	return min((b - a for (a, b) in zip(arr, arr[k - 1:]))) if arr and k else 0


def min_unfairness(arr, k):
	if len(arr) < 2 or k < 2:
		return 0
	t = sorted(arr)
	diff = float('inf')
	for i in range(len(t) - k + 1):
		x = t[i + k - 1] - t[i]
		if x < diff:
			diff = x
	return diff


def min_unfairness(arr, k):
	if k < 2 or len(arr) < 2:
		return 0
	arr = sorted(arr)
	return min((arr[i + k - 1] - arr[i] for i in range(0, len(arr) - k + 1)))


def min_unfairness(arr, k):
	if k < 2 or len(arr) < 2:
		return 0
	arr.sort()
	mindist = float('inf')
	for i in range(len(arr) - k + 1):
		dist = arr[k + i - 1] - arr[i]
		if dist < mindist:
			mindist = dist
	return mindist


import numpy as np

def min_unfairness(arr, k):
	arr = np.sort(np.array(arr))
	if arr.size < 2 or k in (0, 1):
		return 0
	return np.min(arr[k - 1:] - arr[:-k + 1])


min_unfairness = lambda a, k: a.sort() or (k > 0 < len(a) and min((b - a for (a, b) in zip(a, a[k - 1:]))))


def min_unfairness(arr, k):
	if not arr or k == 0:
		return 0
	arr.sort()
	min_unf = float('inf')
	for i in range(len(arr) - k + 1):
		subarr_min = arr[i]
		subarr_max = arr[i + k - 1]
		min_unf = min(min_unf, subarr_max - subarr_min)
	return min_unf


def min_unfairness(arr, k):
	if k < 2:
		return 0
	arr.sort()
	ans = float('inf')
	i = k - 1
	while i < len(arr):
		if abs(arr[i] - arr[i - k + 1]) < ans:
			ans = abs(arr[i] - arr[i - k + 1])
		i += 1
	return ans