Problem 8 presents a new type of problem to solve involving splitting a sequence
into subsequences.
The four adjacent digits in the 1000-digit number that have the greatest product
are 9 x 9 x 8 x 9 = 5832.
Find the thirteen adjacent digits in the 1000-digit number that have the
greatest product. What is the value of this product?
The key to solving this problem is to take each set of 13 consecutive digits,
calculate the product of them and simply pick the highest. To get each set of
digits and find the product we introduct two new utility functions.
The first is euler.iter.window that, as expected, acts as a sliding window on a sequence
(in this case a sequence of characters in a string) and yields each set. It makes
use of the take function from problem 7.
The second is euler.math.product, a simple wrapper around reduce and the
multiply operator to find the product of a sequence.
And so to the solution.
When given the 1000 digit number in the form of a string and a window size
of 13 this solution returns the correct answer of 23514624000 in 9ms.