You work for a government agency that has intercepted a series of encrypted communication signals from a group of bank robbers. The signals contain a long sequence of digits. Your team needs to use various digital signal processing techniques to analyze the signals and identify any patterns that may indicate the planning of a heist.
Your task is to look for patterns in the long sequence of digits in the encrypted signal.
The technique you're going to use here is called the largest series product.
Let's define a few terms, first.
Let's work through an example, with the input
3, there will be three possible series:
"639"is 162 (
6 × 3 × 9 = 162)
"391"is 27 (
3 × 9 × 1 = 27)
"915"is 45 (
9 × 1 × 5 = 45)
"63915"is from the series
"639". So the answer is 162.
Sometimes it is necessary to raise an exception. When you do this, you should always include a meaningful error message to indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. For situations where you know that the error source will be a certain type, you can choose to raise one of the built in error types, but should still include a meaningful message.
This particular exercise requires that you use the raise statement to "throw" a
ValueError when your
largest_product() function receives invalid input. The tests will only pass if you both
exception and include a message with it. Feel free to reuse your code from the
To raise a
ValueError with a message, write the message as an argument to the
# span of numbers is longer than number series raise ValueError("span must be smaller than string length") # span of number is negative raise ValueError("span must not be negative") # series includes non-number input raise ValueError("digits input must only contain digits")