Open
Description
In this exercise, there are two tests which don't seem to be correct:
@Test
fun reports1ForEmptyStringAndEmptyProduct() {
assertEquals(1, Series("").getLargestProduct(0))
}
@Test
fun reports1ForNonEmptyStringAndEmptyProduct() {
assertEquals(1, Series("123").getLargestProduct(0))
}
The requirement is: Given a string of digits, calculate the largest product for a contiguous substring of digits of length n.
Is it logical to return the value 1 when the arguments don't allow to find a solution? It looks like those two tests should return an IllegalArgumentException
:
- first case: contradicts Given a string of digits
- second case: contradicts substring of digits of length n
If this is indeed what the exercise should be, then it should be specified explicitly IMHO.