# Task
 You are given three integers `l, d and x`. Your task is:
```
• determine the minimal integer n 
    such that l ≤ n ≤ d, and the sum of its digits equals x.
• determine the maximal integer m 
    such that l ≤ m ≤ d, and the sum of its digits equals x.
```
It is guaranteed that such numbers always exist.

# Input/Output


 - `[input]` integer `l`

 - `[input]` integer `d`

  `1 ≤ l ≤ d ≤ 10000.`


 - `[input]` integer `x`

  `1 ≤ x ≤ 36`


 - `[output]` an integer array

  Array of two elements, where the first element is `n`, and the second one is `m`.


# Example

 For `l = 500, d = 505, x = 10`, the output should be `[505, 505]`.
 
 For `l = 100, d = 200, x = 10`, the output should be `[109, 190]`.

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def min_and_max(l, d, x):
	

Solutions:
def min_and_max(l, d, x):
	listOfCorect = [num for num in list(range(l, d + 1)) if sum(map(int, str(num))) == x]
	return [min(listOfCorect), max(listOfCorect)]


def min_and_max(l, d, x):
	for n in range(l, d + 1):
		if sum(map(int, str(n))) == x:
			break
	for m in range(d, l - 1, -1):
		if sum(map(int, str(m))) == x:
			break
	return [n, m]


def min_and_max(l, d, x):
	return [next((i for i in range(l, d + 1) if sum((int(n) for n in str(i))) == x)), next((i for i in range(d, l - 1, -1) if sum((int(n) for n in str(i))) == x))]


def min_and_max(l, d, x):

	def min_or_max(l, d, x, end, step):
		return next((i for i in range(l, d + end, step) if sum(map(int, list(str(i)))) == x))
	return [min_or_max(l, d, x, 1, 1), min_or_max(d, l, x, 0, -1)]


func = lambda n: sum(map(int, str(n)))

def min_and_max(l, d, x):
	while func(l) != x:
		l += 1
	while func(d) != x:
		d -= 1
	return [l, d]


from operator import itemgetter

def min_and_max(l, d, x):
	return list(itemgetter(0, -1)([i for i in range(l, d + 1) if sum(map(int, list(str(i)))) == x]))


def min_and_max(l, d, x):
	arr = [i for i in range(l, d + 1) if sum(map(int, str(i))) == x]
	return [arr[0], arr[-1]]


def min_and_max(l, d, x):
	d_sum = lambda n: sum(map(int, str(n)))
	min = next((i for i in range(l, d + 1) if d_sum(i) == x))
	max = next((i for i in range(d, l - 1, -1) if d_sum(i) == x))
	return [min, max]