Create a function that returns the sum of the two lowest positive numbers given an array of minimum 4 positive integers. No floats or non-positive integers will be passed.

For example, when an array is passed like `[19, 5, 42, 2, 77]`, the output should be `7`.

`[10, 343445353, 3453445, 3453545353453]` should return `3453455`.

Difficulty: EASY
Tags: Fundamentals

Data structures
Skill types: Data structures

Starter code:
def sum_two_smallest_numbers(numbers):
	

Solutions:
def sum_two_smallest_numbers(numbers):
	return sum(sorted(numbers)[:2])


def sum_two_smallest_numbers(num_list):
	num_list.sort()
	return num_list[0] + num_list[1]


def sum_two_smallest_numbers(numbers):
	smallest1 = None
	smallest2 = None
	for n in numbers:
		if not smallest1 or n < smallest1:
			smallest2 = smallest1
			smallest1 = n
		elif not smallest2 or n < smallest2:
			smallest2 = n
	return smallest1 + smallest2


from heapq import nsmallest

def sum_two_smallest_numbers(numbers):
	return sum(nsmallest(2, numbers))


def sum_two_smallest_numbers(numbers):
	return sum(sorted(numbers)[:2]) if numbers else None


def sum_two_smallest_numbers(numbers):
	first_min = min(numbers)
	numbers.remove(first_min)
	second_min = min(numbers)
	return first_min + second_min


def sum_two_smallest_numbers(numbers):
	return sorted(numbers)[0] + sorted(numbers)[1]


def sum_two_smallest_numbers(numbers):
	numbers.sort()
	return numbers[0] + numbers[1]


def sum_two_smallest_numbers(numbers):
	return numbers.pop(numbers.index(min(numbers))) + numbers.pop(numbers.index(min(numbers)))


sum_two_smallest_numbers = lambda A: sum(sorted([x for x in A if x > 0])[:2])


def sum_two_smallest_numbers(numbers):
	(min1, min2) = numbers[0:2]
	for i in range(2, len(numbers)):
		if numbers[i] < min2 and numbers[i] < min1:
			min1 = numbers[i]
		elif min1 < numbers[i] < min2:
			min2 = numbers[i]
	return min1 + min2


def sum_two_smallest_numbers(numbers):
	lowest_num1 = numbers[0]
	index = 0
	for i in range(0, len(numbers)):
		if lowest_num1 > numbers[i]:
			lowest_num1 = numbers[i]
			index = i
	numbers.pop(index)
	lowest_num2 = numbers[0]
	for i in range(0, len(numbers)):
		if lowest_num2 > numbers[i]:
			lowest_num2 = numbers[i]
			index = i
	return lowest_num1 + lowest_num2


def sum_two_smallest_numbers(numbers):
	low1 = numbers[0]
	low2 = numbers[1]
	for i in numbers:
		if i < low1:
			low1 = i
	for i in numbers[1:]:
		if i < low2:
			if i != low1:
				low2 = i
	sum = low1 + low2
	return sum


import sys

def sum_two_smallest_numbers(numbers):
	num = []
	num = numbers
	firstnum = sys.maxsize
	secondnum = sys.maxsize
	sum = 0
	for i in range(0, len(num)):
		if num[i] < firstnum:
			firstnum = num[i]
		else:
			{}
	for i in range(0, len(num)):
		if num[i] == firstnum:
			{}
		elif num[i] < secondnum:
			secondnum = num[i]
		else:
			{}
	sum = firstnum + secondnum
	return sum


def sum_two_smallest_numbers(numbers):
	(x, y) = numbers[:2]
	if x > y:
		(x, y) = (y, x)
	for z in numbers[2:]:
		if z < x:
			y = x
			x = z
		elif z < y:
			y = z
	return x + y


def sum_two_smallest_numbers(numbers):
	n1 = min(numbers)
	n2 = max(numbers)
	for n in numbers:
		if n1 < n < n2:
			n2 = n
	return n1 + n2


def sum_two_smallest_numbers(numbers):
	number = numbers
	number.sort(reverse=True)
	a = number.pop()
	b = number.pop()
	return a + b


import heapq

def sum_two_smallest_numbers(numbers):
	two_smallests = heapq.nsmallest(2, numbers)
	return two_smallests[0] + two_smallests[1]


def sum_two_smallest_numbers(numbers):
	numbers.sort()
	subNumbers = numbers[:2]
	return sum(subNumbers)


def sum_two_smallest_numbers(numbers):
	a = min(numbers)
	b = min(numbers, key=lambda n: (n == a, n))
	return a + b


def sum_two_smallest_numbers(numbers):
	(n1, n2) = (numbers[0], numbers[1])
	for i in numbers[2:]:
		if n2 < n1:
			(n2, n1) = (n1, n2)
		if i < n2:
			n2 = i
	return n1 + n2


def sum_two_smallest_numbers(num_array):
	smallest1 = min(num_array)
	index_smallest1 = num_array.index(smallest1)
	smallest2 = max(num_array)
	length_array = num_array.__len__()
	index = 0
	while index < length_array:
		if not index == index_smallest1 and num_array[index] <= smallest2:
			smallest2 = num_array[index]
		index += 1
	return smallest1 + smallest2


def sum_two_smallest_numbers(numbers):
	sorted_list = sorted(numbers)
	sum_of_smallest_number = sorted_list[0] + sorted_list[1]
	return sum_of_smallest_number


def sum_two_smallest_numbers(L):
	x = min(L)
	L.remove(x)
	y = min(L)
	return x + y


def sum_two_smallest_numbers(x):
	L = []
	L.append(min(x))
	y = x.remove(min(x))
	L.append(min(x))
	return sum(L)


def sum_two_smallest_numbers(numbers):
	(first, second) = (float('inf'), float('inf'))
	for n in numbers:
		if n < first:
			(first, second) = (n, first)
		elif n < second:
			second = n
	return first + second


def sum_two_smallest_numbers(numbers):
	result = 0
	for i in range(2):
		min = numbers[0]
		for num in numbers:
			if num < min:
				min = num
		numbers[numbers.index(min)] = max(numbers) + 1
		result += min
	return result


def sum_two_smallest_numbers(numbers):
	for item in numbers:
		if item < 0:
			numbers.remove(item)
	return sum(sorted(numbers)[:2])


def sum_two_smallest_numbers(numbers):
	m1 = min(numbers)
	ind = numbers.index(min(numbers))
	numbers[ind] = max(numbers)
	m2 = min(numbers)
	numbers[ind] = m1
	return m1 + m2


def sum_two_smallest_numbers(numbers):
	min1 = 0
	min2 = 0
	max = 0
	for x in numbers:
		if x >= max:
			max = x
	min1 = max
	for y in numbers:
		if y < min1:
			min1 = y
	min2 = max
	for z in numbers:
		if z < min2:
			if z != min1:
				min2 = z
	print(numbers)
	print(('Maximo =', max))
	print(('Minimo 1=', min1))
	print(('Minimo 2=', min2))
	returnVal = min1 + min2
	print(('Suma=', returnVal))
	return returnVal


def sum_two_smallest_numbers(numbers):
	(a, b) = numbers[:2]
	for i in range(2, len(numbers)):
		(a, b, c) = sorted((a, b, numbers[i]))
	return a + b


def sum_two_smallest_numbers(numbers):
	min_1 = min(numbers)
	numbers.remove(min_1)
	min_2 = min(numbers)
	return min_1 + min_2


def sum_two_smallest_numbers(numbers):
	min1 = min(numbers)
	numbers.remove(min1)
	min2 = min(numbers)
	return min1 + min2


sum_two_smallest_numbers = lambda a: sum(sorted(a)[:2])


def sum_two_smallest_numbers(x):
	return sum(sorted(x)[:2])


import sys

def sum_two_smallest_numbers(numbers):
	numA = sys.maxsize
	numB = sys.maxsize
	for number in numbers:
		if number >= 0:
			if number < numA:
				numB = numA
				numA = number
			elif number < numB:
				numB = number
	return numA + numB


import sys

def sum_two_smallest_numbers(numbers):
	small_1 = sys.maxsize
	small_2 = sys.maxsize
	for elem in numbers:
		if elem < small_1:
			small_2 = small_1
			small_1 = elem
		elif elem < small_2:
			small_2 = elem
	return small_1 + small_2


def sum_two_smallest_numbers(numbers):
	ch1 = min(numbers)
	numbers.pop(numbers.index(ch1))
	ch2 = min(numbers)
	return ch1 + ch2


def find_maximum(numbers):
	max_ = numbers[0]
	index = 0
	for (count, num) in enumerate(numbers):
		if num > max_:
			max_ = num
			index = count
	return index

def sum_two_smallest_numbers(numbers):
	top2 = [numbers[0], numbers[1]]
	max_index = find_maximum(top2)
	for num in numbers[2:]:
		if num < top2[max_index]:
			top2[max_index] = num
			max_index = find_maximum(top2)
	return top2[0] + top2[1]


def sum_two_smallest_numbers(numbers):
	sorted_numbers = sorted(numbers)
	result = sorted_numbers[0] + sorted_numbers[1]
	return result