Complete the `greatestProduct` method so that it'll find the greatest product of five consecutive digits in the given string of digits.

For example:

The input string always has more than five digits.

Adapted from Project Euler.

Source: codewars | Difficulty: EASY
Tags: Mathematics

Starter code: def greatest_product(n):
	

Solutions:
from itertools import islice
from functools import reduce

def greatest_product(n):
	numbers = [int(value) for value in n]
	result = [reduce(lambda x, y: x * y, islice(numbers, i, i + 5), 1) for i in range(len(numbers) - 4)]
	return max(result)


def product(list):
	p = 1
	for i in list:
		p *= int(i)
	return p

def greatest_product(list):
	res = []
	mul = 1
	while len(list) >= 5:
		res.append(product(list[:5]))
		list = list[1:]
	return max(res)


def greatest_product(n):
	L = []
	L1 = []
	for i in n:
		L.append(int(i))
	for i in range(len(L) - 4):
		a = L[i] * L[i + 1] * L[i + 2] * L[i + 3] * L[i + 4]
		L1.append(a)
	return max(L1)


def greatest_product(n):
	l = len(n)
	t = []
	for i in range(l - 4):
		a = int(n[i]) * int(n[i + 1]) * int(n[i + 2]) * int(n[i + 3]) * int(n[i + 4])
		t.append(a)
	print(t)
	ans = max(t)
	return ans


from functools import reduce

def greatest_product(n):
	l = list(map(int, list(n)))
	return max([reduce(lambda x, y: x * y, l[i:i + 5]) for i in range(len(l)) if len(l[i:i + 5]) == 5])


from functools import reduce
from operator import __mul__

def greatest_product(n):
	return max([reduce(__mul__, list(map(int, x))) for x in [x for x in [n[i:i + 5] for i in range(len(n))] if len(x) == 5]])


import numpy

def greatest_product(n):
	lst = []
	for a in range(0, len(n) - 4):
		lst.append(numpy.prod(list(map(int, list(n[a:a + 5])))))
	return max(lst)


from functools import reduce

def greatest_product(a):
	return max([reduce(lambda a, b: a * b, map(int, a[i:i + 5])) for i in range(0, len(a) - 4)])


def greatest_product(n, num_consecutive_digits=5):
	digits = [int(digit) for digit in n]
	greatest = 0
	for i in range(len(digits) - num_consecutive_digits + 1):
		product = 1
		for j in range(num_consecutive_digits):
			product *= digits[i + j]
		greatest = max(product, greatest)
	return greatest


from functools import reduce

def greatest_product(n):
	test = [reduce(lambda x, y: x * y, list(map(int, n[i:i + 5]))) for i in range(0, len(n) - 4)]
	return max(test)