Sha256: 3a1b954932753a9345efed1c849bd15bd9dc5e74ee4a069e5b28b10e4521c61c
Contents?: true
Size: 547 Bytes
Versions: 176
Compression:
Stored size: 547 Bytes
Contents
object Series { private def digits(s: String): List[Int] = s.filter(_.isDigit).map(_.asDigit).toList private def slices(n: Int, digits: List[Int]): List[List[Int]] = digits.tails.filter(xs => xs.length >= n).map(_.take(n)).toList def largestProduct(n: Int, s: String): Option[Int] = if (n < 0) None else { val ds = digits(s) if (ds.length < s.length) None else { slices(n, ds) match { case Nil => None case xs => Some(xs.map(_.product).max) } } } }
Version data entries
176 entries across 176 versions & 1 rubygems