### Introduction and Warm-up (Highly recommended)

### [Playing With Lists/Arrays Series](https://www.codewars.com/collections/playing-with-lists-slash-arrays)
___

## Task

**_Given_** an *array/list [] of integers* , **_Find the product of the k maximal_** numbers.
___

### Notes 

* **_Array/list_** size is *at least 3* .

* **_Array/list's numbers_**  *Will be* **_mixture of positives , negatives and zeros_** 

* **_Repetition_** of numbers in *the array/list could occur*.
___

### Input >> Output Examples 

```
maxProduct ({4, 3, 5}, 2) ==>  return (20)
```

#### _Explanation_:

* **_Since_** *the size (k) equal 2* , then **_the subsequence of size 2_** *whose gives* **_product of maxima_**  is `5 * 4 = 20` .
___

```
maxProduct ({8, 10 , 9, 7}, 3) ==>  return (720)
```

#### _Explanation_:

* **_Since_** *the size (k) equal 3* , then **_the subsequence of size 3_** *whose gives* **_product of maxima_**  is ` 8 * 9 * 10 = 720` .
___

```
maxProduct ({10, 8, 3, 2, 1, 4, 10}, 5) ==> return (9600)
```

#### _Explanation_:

* **_Since_** *the size (k) equal 5* , then **_the subsequence of size 5_** *whose gives* **_product of maxima_**  is ` 10 * 10 * 8 * 4 * 3 = 9600` .
___

```
maxProduct ({-4, -27, -15, -6, -1}, 2) ==> return (4)
```

#### _Explanation_:

* **_Since_** *the size (k) equal 2* , then **_the subsequence of size 2_** *whose gives* **_product of maxima_**  is ` -4 * -1 = 4` .
___

```
maxProduct ({10, 3, -1, -27} , 3)  return (-30)
``` 

#### _Explanation_:
* **_Since_** *the size (k) equal 3* , then **_the subsequence of size 3_** *whose gives* **_product of maxima_**  is ` 10 * 3 * -1 = -30 ` .
___
___
___
___

#### [Playing with Numbers Series](https://www.codewars.com/collections/playing-with-numbers)

#### [Playing With Lists/Arrays Series](https://www.codewars.com/collections/playing-with-lists-slash-arrays)

#### [For More Enjoyable Katas](http://www.codewars.com/users/MrZizoScream/authored)
___

##### ALL translations are welcomed

##### Enjoy Learning !!
##### Zizou

Difficulty: EASY
Tags: Fundamentals

Data structures
Skill types: Data structures

Starter code:
def max_product(lst, n_largest_elements):
	

Solutions:
def max_product(lst, n_largest_elements):
	lst_largest = sorted(lst)[-n_largest_elements:]
	prod = 1
	for number in lst_largest:
		prod *= number
	return prod


def max_product(lst, n):
	from functools import reduce
	return reduce(lambda x, y: x * y, sorted(lst, reverse=True)[:n])


def max_product(lst, n_largest_elements):
	sorted_lst = sorted(lst, reverse=True)
	product = 1
	for i in range(n_largest_elements):
		product *= sorted_lst[i]
	return product


from functools import reduce
from operator import mul
max_product = lambda lst, k: reduce(mul, sorted(lst)[-k:])


def max_product(lst, n):
	return __import__('functools').reduce(int.__mul__, sorted(lst)[-n:])


def max_product(lst, n, res=1):
	for i in sorted(lst)[-n:]:
		res *= i
	return res


def max_product(lst, n):
	lst = sorted(lst)[::-1]
	for _ in range(n - 1):
		rec(lst)
	return lst[0]

def rec(arr):
	arr[0] = arr.pop(0) * arr[0]
	return arr


def max_product(lst, n):
	return __import__('functools').reduce(lambda x, y: x * y, __import__('heapq').nlargest(n, lst))


def max_product(lst, l):
	st = sorted(lst)
	res = st[-l:]
	const = 1
	for i in res:
		const = const * i
	return const


def max_product(lst, n_largest_elements):
	p = 1
	for x in sorted(lst, reverse=True)[:n_largest_elements]:
		p *= x
	return p


def max_product(lst, n):
	return __import__('functools').reduce(lambda x, y: x * y, sorted(lst, reverse=True)[:n])


def max_product(lst, n):
	a = lst.sort(reverse=True)
	i = 0
	sum = 1
	while i < n:
		sum = sum * lst[i]
		i += 1
	return sum


def max_product(lst, n_largest_elements):
	l = sorted(lst, reverse=True)
	result = l[0]
	for i in range(1, n_largest_elements):
		result *= l[i]
	return result


def max_product(lst, n_largest_elements):
	lst = sorted(lst)
	product = 1
	for i in range(n_largest_elements):
		product *= lst[-i - 1]
	return product


import functools

def max_product(lst, n_largest_elements):
	return functools.reduce(lambda x, y: x * y, sorted(lst, reverse=True)[:n_largest_elements])


from operator import mul
from functools import reduce

def max_product(lst, n_largest_elements):
	return reduce(mul, sorted(lst)[::-1][:n_largest_elements])


import functools as f

def max_product(lst, n):
	return f.reduce(lambda a, b: a * b, sorted(lst)[-n:])


def max_product(lst, n_largest_elements):
	total = 1
	for x in sorted(lst, reverse=True)[0:n_largest_elements]:
		total *= x
	return total


max_product = lambda a, n: __import__('functools').reduce(lambda x, y: x * y, sorted(a)[-n:])


def max_product(lst, n):
	lst = sorted(lst, reverse=True)
	result = lst[0]
	for i in range(1, n):
		result *= lst[i]
	return result


from functools import reduce
max_product = lambda lst, n: reduce(lambda a, b: a * b, sorted(lst)[-n:], 1)


def max_product(lst, n_largest_elements):
	from functools import reduce
	return reduce(lambda x, y: x * y, sorted(lst)[-n_largest_elements:])


import operator
import functools

def max_product(lst, n_largest_elements):
	return functools.reduce(operator.mul, sorted(lst, reverse=True)[:n_largest_elements])


def max_product(lst, n):
	x = 1
	for i in sorted(lst, reverse=True)[:n]:
		x *= i
	return x


import heapq
from functools import reduce

def max_product(lst, n):
	return reduce(lambda x, y: x * y, heapq.nlargest(n, lst))


from functools import reduce
from heapq import nlargest

def max_product(lst, n_largest_elements):
	return reduce(int.__mul__, nlargest(n_largest_elements, lst))


def mult(s):
	re = s[0]
	for i in s[1:]:
		re = re * i
	return re

def max_product(lst, n):
	return mult(sorted(lst, reverse=True)[:n])


def max_product(lst, n_largest_elements):
	out = 1
	order = sorted(lst)
	for _ in range(n_largest_elements):
		out *= order.pop()
	return out


def max_product(lst, n_largest_elements):
	sort_lst = sorted(lst)
	output = 1
	for i in range(1, n_largest_elements + 1):
		output = output * sort_lst[-i]
	return output


def max_product(lst, n_largest_elements):
	answer = 1
	lst = sorted(lst)
	for i in lst[-n_largest_elements:]:
		answer *= i
	return answer


def max_product(lst, n_largest_elements):
	lst.sort()
	x = lst[-1]
	for i in range(n_largest_elements - 1):
		lst.pop(-1)
		x *= lst[-1]
	return x


def max_product(lst, n_largest_elements):
	out = 1
	work = sorted(lst, reverse=True)
	for i in range(n_largest_elements):
		out *= work[i]
	return out


def max_product(l, n):
	l = sorted(l)[::-1]
	res = 1
	for i in range(n):
		res *= l[i]
	return res


max_product = lambda lst, n_largest_elements: __import__('functools').reduce(lambda a, b: a * b, sorted(lst)[-n_largest_elements:])


from functools import reduce
max_product = lambda lst, n_largest_elements: reduce(lambda a, b: a * b, sorted(lst)[-n_largest_elements:])


from functools import reduce

def max_product(ls, k):
	return reduce(lambda a, c: a * c, sorted(ls, reverse=True)[:k], 1)


from functools import reduce

def max_product(A, n):
	prod = lambda A: reduce(lambda a, b: a * b, A)
	return prod(sorted(A, reverse=True)[:n])


def max_product(lst, n_largest_elements):
	lst.sort(reverse=True)
	total = 1
	for num in range(n_largest_elements):
		total = total * lst[num]
	return total


def max_product(lst, n_largest_elements):
	lst = sorted(lst, reverse=True)[0:n_largest_elements]
	n = 1
	for x in range(n_largest_elements):
		n *= lst[x]
	return n


def max_product(lst, n_largest_elements):
	lst = sorted(lst)[::-1]
	c = 1
	for i in range(n_largest_elements):
		c = c * lst[i]
	return c


from functools import reduce

def max_product(L, k):
	return reduce(lambda a, b: a * b, sorted(L, reverse=True)[:k])


def max_product(arr, n):
	b = sorted(arr, reverse=True)
	acc = 1
	for i in b[:n]:
		acc *= i
	return acc


from functools import reduce

def max_product(l, n):
	return reduce(lambda x, y: x * y, sorted(l)[-n:])


def max_product(lst, n_largest_elements):
	a = sorted(lst)[-n_largest_elements:]
	prod = 1
	for i in a:
		prod = prod * i
	return prod


from operator import mul
from heapq import nlargest
from functools import reduce

def max_product(l, n):
	return reduce(mul, nlargest(n, l))


from functools import reduce
from operator import mul
max_product = lambda l, n: reduce(mul, sorted(l, reverse=True)[:n])


def max_product(lst, n_largest_elements):
	lst = sorted(lst)
	result = 1
	for i in range(1, n_largest_elements + 1):
		x = i - i - i
		result *= lst[x]
	return result


def max_product(lst, n_largest_elements):
	accumulator = 1
	lst.sort()
	if len(lst) == 0:
		return lst[0]
	else:
		x = lst[-n_largest_elements:]
		for eachnumber in x:
			accumulator = accumulator * eachnumber
		return accumulator


def max_product(lst, n):
	lst.sort(reverse=1)
	res = 1
	for i in lst[:n]:
		res *= i
	return res


def max_product(lst, n_largest_elements):
	a = sorted(lst, reverse=True)
	b = 1
	for i in range(n_largest_elements):
		b *= a[i]
	return b


def max_product(lst, n):
	result = 1
	for number in sorted(lst)[-n:]:
		result *= number
	return result


def max_product(lst, n_largest_elements):
	lst.sort(reverse=True)
	m = 1
	for a in range(n_largest_elements):
		m *= lst[a]
	return m


def max_product(lst, n_largest_elements):
	temp = sorted(lst, reverse=True)
	total = 1
	for i in range(n_largest_elements):
		total *= temp[i]
	return total


from functools import *

def max_product(lst, n_largest_elements):
	return reduce(lambda a, b: a * b, sorted(lst)[-n_largest_elements:])


from functools import reduce as f

def max_product(lst, n):
	return f(lambda x, y: x * y, sorted(lst)[::-1][:n])


def max_product(lst, n_largest_elements):
	a = [x for x in sorted(lst, reverse=True)][:n_largest_elements]
	s = 1
	for x in a:
		s = s * x
	return s


def max_product(lst, n_largest_elements):
	sort = sorted(lst)
	res = []
	for i in range(n_largest_elements):
		res.append(sort.pop())
	ans = 1
	for num in res:
		ans *= num
	return ans


from functools import reduce

def max_product(lst, n_largest_elements):
	return reduce(int.__mul__, sorted(lst)[-n_largest_elements:])


from functools import reduce

def max_product(l, k):
	return reduce(lambda res, x: res * x, sorted(l)[-k:])


def max_product(lst, n):
	a = sorted(lst, reverse=True)
	ans = 1
	for i in range(0, n):
		ans *= a[i]
	return ans


def max_product(lst, n_largest_elements):
	sorted_list = sorted(lst, reverse=True)
	list = sorted_list[:n_largest_elements]
	res = 1
	for i in list:
		res = res * i
	return res


from functools import reduce

def max_product(lst, n):
	st = sorted(lst)
	lg = st[-n:]
	return reduce(lambda x, y: x * y, lg)


from functools import reduce

def max_product(lst, n):
	res = sorted(lst)[-n:]
	return reduce(lambda x, y: x * y, res)


import numpy

def max_product(lst, n_largest_elements):
	list = sorted(lst, reverse=True)[:n_largest_elements]
	res = 1
	for i in list:
		res = res * i
	return res


def max_product(lst, n_largest_elements):
	arr = sorted(lst)[-n_largest_elements:]
	output = 1
	for elem in arr:
		output *= elem
	return output


def max_product(lst, n_largest_elements):
	nums = sorted(lst)
	product = 1
	for num in nums[-n_largest_elements:]:
		product = product * num
	return product


from functools import reduce
from operator import mul
from typing import List

def max_product(lst: List[int], n_largest_elements: int) -> int:
	return reduce(mul, sorted(lst)[-n_largest_elements:])


def max_product(lst, n):
	s = 1
	ls = sorted(lst, reverse=True)
	for i in ls[:n]:
		s *= i
	return s


def max_product(lst, n_largest_elements):
	answer = 1
	lst.sort(reverse=True)
	for x in range(n_largest_elements):
		answer *= lst[x]
	return answer


def max_product(arr, n):
	prod = 1
	arr = list(sorted(arr, reverse=True))
	for i in range(n):
		prod *= arr[i]
	return prod


def max_product(lst, n_largest_elements):
	lst = sorted(lst)
	res = 1
	for i in lst[-n_largest_elements:]:
		res *= i
	return res


def max_product(lst, n):
	from functools import reduce
	lst = [i for i in sorted(lst, reverse=True)[:n]]
	return reduce(lambda x, y: x * y, lst)


def max_product(lst, n_largest_elements):
	lst.sort()
	product = 1
	for i in lst[len(lst) - n_largest_elements:]:
		product *= i
	return product


def max_product(lst, n_largest_elements):
	a = sorted(lst)
	c = 1
	for i in a[-n_largest_elements:]:
		c = c * i
	return c


def max_product(lst, n_largest_elements):
	lst.sort()
	c = 1
	for i in lst[-n_largest_elements:]:
		c = i * c
	return c


from heapq import nlargest
from functools import reduce
from operator import mul
max_product = lambda lst, k: reduce(mul, nlargest(k, lst))


def max_product(lst, n_largest_elements):
	x = sorted(lst)[-n_largest_elements:]
	p = 1
	for i in x:
		p *= i
	return p