Given an array of integers.

Return an array, where the first element is the count of positives numbers and the second element is sum of negative numbers.

If the input array is empty or null, return an empty array.

# Example

For input `[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14, -15]`, you should return `[10, -65]`.

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Data structures

Starter code: def count_positives_sum_negatives(arr):
	

Solutions:
def count_positives_sum_negatives(arr):
	if not arr:
		return []
	pos = 0
	neg = 0
	for x in arr:
		if x > 0:
			pos += 1
		if x < 0:
			neg += x
	return [pos, neg]


def count_positives_sum_negatives(arr):
	pos = sum((1 for x in arr if x > 0))
	neg = sum((x for x in arr if x < 0))
	return [pos, neg] if len(arr) else []


def count_positives_sum_negatives(arr):
	return [len([x for x in arr if x > 0])] + [sum((y for y in arr if y < 0))] if arr else []


def count_positives_sum_negatives(arr):
	return [sum((n > 0 for n in arr)), sum((n for n in arr if n < 0))] if arr else []


def count_positives_sum_negatives(arr):
	output = []
	if arr:
		output.append(sum([1 for x in arr if x > 0]))
		output.append(sum([x for x in arr if x < 0]))
	return output


def count_positives_sum_negatives(input):
	if not input:
		return []
	count_ = 0
	sum_ = 0
	for element in input:
		if element > 0:
			count_ += 1
		elif element < 0:
			sum_ += element
	return [count_, sum_]


count_positives_sum_negatives = lambda arr: [len([e for e in arr if e > 0]), sum((e for e in arr if e < 0))] if arr else []


def count_positives_sum_negatives(arr):
	if not arr:
		return arr
	return [sum((1 for x in arr if x > 0)), sum((x for x in arr if x < 0))]


def count_positives_sum_negatives(arr):
	if arr == []:
		return []
	result = [0, 0]
	for value in arr:
		if value > 0:
			result[0] += 1
		else:
			result[1] += value
	return result


def count_positives_sum_negatives(arr):
	pos = 0
	neg = 0
	zer = 0
	for x in arr:
		if x < 0:
			neg += x
		elif x > 0:
			pos += 1
		else:
			zer += 0
	return [pos, neg] if zer != len(arr) else []


from functools import reduce

def count_positives_sum_negatives(arr):
	return arr and reduce(lambda x, y: [x[0] + (y > 0), x[1] + y * (y < 0)], arr, [0, 0])


def count_positives_sum_negatives(arr):
	if arr is None or len(arr) == 0:
		return []
	non_positives = [x for x in arr if x < 1]
	count_positives = len(arr) - len(non_positives)
	sum_negatives = sum(non_positives)
	return [count_positives, sum_negatives]


def count_positives_sum_negatives(arr):
	return [len([i for i in arr if i > 0]), sum([i for i in arr if i < 0])] if arr else []


def count_positives_sum_negatives(arr):
	if not arr:
		return []
	else:
		pos = sum((int > 0 for int in arr))
		neg = sum((int for int in arr if int < 0))
		return [pos, neg]


def count_positives_sum_negatives(arr):
	if not arr:
		return []
	else:
		x = sum((1 for i in arr if i >= 1))
		y = sum((i for i in arr if i < 1))
		return [x, y]


def count_positives_sum_negatives(arr):
	return [len([x for x in arr if x > 0]), sum(filter(lambda x: x < 0, arr))] if len(arr) != 0 else []


def count_positives_sum_negatives(arr):
	if len(arr) == 0:
		return []
	pos = 0
	neg = 0
	for i in arr:
		if i > 0:
			pos += 1
		else:
			neg += i
	a = [pos, neg]
	return a


def count_positives_sum_negatives(arr):
	if not arr:
		return []
	count = len(arr)
	sum = 0
	for num in arr:
		if num <= 0:
			count -= 1
			sum += num
	return [count, sum]


def count_positives_sum_negatives(arr):
	if not arr:
		return arr
	count = 0
	su = []
	for i in arr:
		if i > 0:
			count += 1
		else:
			su.append(i)
	return [count, sum(su)]


def count_positives_sum_negatives(arr):
	(count, sumnegative) = (0, 0)
	for e in arr:
		if e > 0:
			count += 1
		else:
			sumnegative += e
	return [] if arr == [] else [count, sumnegative]


def count_positives_sum_negatives(arr):
	a = 0
	s = 0
	if not arr:
		return []
	for i in arr:
		if i > 0:
			a = a + 1
		else:
			s = s + i
	return [a, s]


def count_positives_sum_negatives(arr):
	a = [0, 0]
	for i in arr:
		if i < 0:
			a[1] += i
		elif i > 0:
			a[0] += 1
	return a if arr else []


def count_positives_sum_negatives(arr):
	if len(arr) == 0:
		return []
	count_positive = 0
	sum_negative = 0
	for i in range(len(arr)):
		if arr[i] > 0:
			count_positive = count_positive + 1
		else:
			sum_negative = sum_negative + arr[i]
	return [count_positive, sum_negative]


def count_positives_sum_negatives(arr):
	a = [0, 0]
	if not arr:
		return []
	for n in range(0, len(arr)):
		if arr[n] > 0:
			a[0] += 1
		elif arr[n] < 0:
			a[1] += arr[n]
	return a


def count_positives_sum_negatives(arr):
	if len(arr) == 0:
		return []
	positives = list(filter(lambda x: x > 0, arr))
	negatives = list(filter(lambda x: x < 0, arr))
	return [len(positives), sum(negatives)]


def count_positives_sum_negatives(arr):
	count = 0
	suma = 0
	if arr == []:
		return []
	else:
		for number in arr:
			if number > 0:
				count = count + 1
			elif number <= 0:
				suma = suma + number
		return [count, suma]


def count_positives_sum_negatives(arr):
	p = 0
	n = 0
	if arr == []:
		return []
	for i in arr:
		if i != 0:
			if i > 0:
				p += 1
			else:
				n += i
	if p == 0 and n == 0:
		return [0, 0]
	return [p, n]


def count_positives_sum_negatives(arr):
	num = 0
	if len(arr) == 0:
		return []
	else:
		for x in arr:
			if x > 0:
				num += 1
		s = sum((x for x in arr if x < 0))
		return [num, s]


def count_positives_sum_negatives(arr):
	return arr and [sum((1 for a in arr if a > 0)), sum((a for a in arr if a < 0))] or []


def count_positives_sum_negatives(arr):
	result = [0, 0]
	for i in arr:
		result[i < 0] += 1 if i > 0 else i
	return [] if arr == [] else result


def count_positives_sum_negatives(x):
	return [] if len(x) == 0 else [sum([[x.count(i), 1][1] for i in x if i > 0]), sum([i for i in x if i < 0])]


def count_positives_sum_negatives(arr):
	res = []
	if arr:
		i = 0
		j = 0
		for num in arr:
			if num > 0:
				i = i + 1
			else:
				j = num + j
		res = [i, j]
	return res


def count_positives_sum_negatives(arr):
	if arr.__len__() == 0:
		return []
	else:
		(sum_value, count) = (0, 0)
		for value in arr:
			if value < 0:
				sum_value += value
			elif value > 0:
				count += 1
			else:
				continue
		return [count, sum_value]


def count_positives_sum_negatives(arr):
	return [] if arr == [] else [sum((1 for x in arr if x > 0)), sum((x for x in arr if x < 0))]


def count_positives_sum_negatives(arr):
	if arr:
		return [len([x for x in arr if x > 0]), sum([x for x in arr if x < 0])]
	return []


def count_positives_sum_negatives(arr):
	return [] if arr == None or arr == [] else [len(list(filter(lambda x: x > 0, arr))), sum(filter(lambda x: x < 0, arr))]


def count_positives_sum_negatives(arr):
	if arr == []:
		return []
	c = 0
	a = []
	i = [i for i in arr if i > 0]
	n = [i for i in arr if i < 0]
	a.append(len(i))
	a.append(sum(n))
	return a


def count_positives_sum_negatives(arr):
	if arr == []:
		return []
	countPos = len([x for x in arr if x > 0])
	sumNeg = sum((x for x in arr if x < 0))
	return [countPos, sumNeg]


def count_positives_sum_negatives(arr):
	for a in arr:
		while True:
			amount = len([a for a in arr if a > 0])
			suma = sum((a for a in arr if a < 0))
			return [amount, suma]
	else:
		return []


def count_positives_sum_negatives(arr):
	i = j = 0
	if not arr:
		return []
	for num in arr:
		if num > 0:
			i += 1
		elif num < 0:
			j += num
		else:
			pass
	return [i, j]


def count_positives_sum_negatives(a):
	return a and [sum((i > 0 for i in a)), sum((i for i in a if i < 0))]


def count_positives_sum_negatives(arr):
	count = 0
	summ = 0
	if len(arr) == 0:
		return []
	else:
		for i in arr:
			if i > 0:
				count += 1
			else:
				summ += i
		return [count, summ]


def count_positives_sum_negatives(arr):
	return [[sum((i > 0 for i in arr)), sum((i for i in arr if i < 0))], []][arr == []]


def count_positives_sum_negatives(arr):
	if arr == []:
		return []
	pos = sum([i > 0 for i in arr])
	neg = sum((i for i in arr if i < 0))
	return [pos, neg]


def count_positives_sum_negatives(arr):
	return [[x > 0 for x in arr].count(True), sum([x for x in arr if x < 0])] if arr else []


def count_positives_sum_negatives(arr):
	if len(arr) == 0:
		return []
	else:
		CountPos = 0
		SumNeg = 0
		for Index in range(len(arr)):
			if arr[Index] > 0:
				CountPos = CountPos + 1
			elif arr[Index] < 0:
				SumNeg = SumNeg + arr[Index]
		return [CountPos, SumNeg]


def count_positives_sum_negatives(arr):
	pos = 0
	neg = 0
	if arr == []:
		return []
	for i in arr:
		if i > 0:
			pos = pos + 1
			print(pos)
		elif i < 0:
			neg = neg + i
	return [pos, neg]


def count_positives_sum_negatives(arr):
	res = [0, 0]
	for item in arr:
		if item > 0:
			res[0] += 1
		else:
			res[1] += item
	return res if arr else []


def count_positives_sum_negatives(arr):
	neg = 0
	neg = sum((el for el in arr if el < 0))
	pos = 0
	pos = len([el for el in arr if el > 0])
	return [pos, neg] if arr else []


def count_positives_sum_negatives(arr):
	neg_int = 0
	pos_int = 0
	if arr == []:
		return arr
	for i in arr:
		if i < 0:
			neg_int += i
		if i > 0:
			pos_int += 1
	return [pos_int, neg_int]


def count_positives_sum_negatives(arr):
	if not arr or not len(arr):
		return []
	(p, n) = (0, 0)
	for e in arr:
		(p, n) = (p + 1, n) if e > 0 else (p, n + e)
	return [p, n]


def count_positives_sum_negatives(arr):
	if arr == []:
		return []
	first = sum((x > 0 for x in arr))
	second = 0
	for i in range(len(arr)):
		if int(arr[i]) < 0:
			second += int(arr[i])
	return [first, second]


def count_positives_sum_negatives(arr):
	count_pos = 0
	sum_neg = 0
	for num in arr:
		if num > 0:
			count_pos += 1
		if num < 0:
			sum_neg += num
	return [count_pos] + [sum_neg] if arr else []


def count_positives_sum_negatives(arr):
	positive = 0
	negative = 0
	if arr:
		for x in arr:
			if x <= 0:
				negative += x
			else:
				positive += 1
		return [positive, negative]
	else:
		return []


def count_positives_sum_negatives(arr):
	a = []
	b = []
	if len(arr) == 0:
		return []
	for i in arr:
		if i > 0:
			a.append(i)
		elif i < 0:
			b.append(i)
	c = len(a)
	d = sum(b)
	m = [c, d]
	return m


def count_positives_sum_negatives(arr):
	n_array = []
	count = 0
	sum = 0
	for i in arr:
		if i > 0:
			count += 1
		if i < 0:
			sum += i
	n_array.append(count)
	n_array.append(sum)
	if arr == []:
		return []
	elif arr == [0, 0]:
		return [0, 0]
	return n_array


def count_positives_sum_negatives(arr):
	sum = 0
	count = 0
	tableau = 2 * [0]
	if arr == []:
		return []
	else:
		for loop in range(len(arr)):
			if arr[loop] > 0:
				sum = sum + 1
			else:
				count = count + arr[loop]
			tableau = [sum, count]
		return tableau


def count_positives_sum_negatives(arr):
	kol_polozh = 0
	summ_otric = 0
	a = []
	if arr == []:
		return []
	else:
		for i in range(0, len(arr), 1):
			if arr[i] > 0:
				kol_polozh = kol_polozh + 1
			if arr[i] < 0:
				summ_otric = summ_otric + arr[i]
			a = [kol_polozh, summ_otric]
	return a


def count_positives_sum_negatives(arr):
	pos = 0
	neg = 0
	res = []
	if len(arr) > 0:
		for x in arr:
			if x > 0:
				pos += 1
			else:
				neg += x
		res.append(pos)
		res.append(neg)
	return res


def count_positives_sum_negatives(arr):
	negsum = 0
	positive = 0
	for i in arr:
		if i > 0:
			positive += 1
		elif i < 0:
			negsum += i
	if arr == []:
		return arr
	else:
		return [positive, negsum]


def count_positives_sum_negatives(arr):
	if arr == []:
		return []
	posTot = 0
	negSum = 0
	for number in arr:
		if number <= 0:
			negSum += number
		else:
			posTot += 1
	return [posTot, negSum]


def count_positives_sum_negatives(arr):
	if arr == []:
		return []
	sum = 0
	count = 0
	for number in arr:
		if number < 0:
			sum += number
		if number > 0:
			count += 1
	return [count, sum]


def count_positives_sum_negatives(arr):
	negativeTotal = 0
	positiveTotal = 0
	for i in arr:
		if i > 0:
			positiveTotal += 1
		else:
			negativeTotal += i
	if len(arr) == 0:
		return []
	else:
		return [positiveTotal, negativeTotal]


def count_positives_sum_negatives(arr):
	if not arr:
		return []
	(n_pos, sum_neg) = (0, 0)
	for v in arr:
		if v > 0:
			n_pos += 1
		elif v < 0:
			sum_neg += v
	return [n_pos, sum_neg]


from functools import reduce

def count_positives_sum_negatives(arr):
	count = 0
	for x in arr:
		if x > 0:
			count += 1
	return [count, sum((x for x in arr if x < 0))] if len(arr) > 0 else []


def count_positives_sum_negatives(arr):
	if not arr:
		return arr
	(count, sum_) = (0, 0)
	for number in arr:
		if number > 0:
			count += 1
		elif number < 0:
			sum_ += number
	return [count, sum_]


def count_positives_sum_negatives(arr):
	if not arr:
		return []
	sum_of_negative = 0
	positive_num = 0
	for i in arr:
		if i <= 0:
			sum_of_negative += i
		else:
			positive_num += 1
	return [positive_num, sum_of_negative]


def count_positives_sum_negatives(arr):
	positive = 0
	negative = 0
	ans = []
	if not arr:
		return ans
	else:
		for i in range(len(arr)):
			if arr[i] > 0:
				positive = positive + 1
				print('positive: ', positive)
			else:
				negative = negative + arr[i]
				print('negative: ', negative)
		ans = [positive, negative]
		return ans