class Series(val series: String){
    init {
        require(series.all { it.isDigit() })
    }
    fun getLargestProduct(length: Int):Long?{
        require(length >= 0)
        require(length <= series.length)
        var prodList = mutableListOf<Long>()
        for (i in 0..(series.length - (length))){
            val listOfInts: List<Long> = series.substring(i.. i + (length - 1))
                    .fold(mutableListOf<Long>(), { acc: MutableList<Long>, c: Char -> acc.add(c.toString().toLong()); acc})
            prodList.add(listOfInts.fold(1, { acc: Long, i: Long-> acc * i }))
        }
        return prodList.max()?.toLong() ?: 1
    }
}