Sha256: 5ac8d7fada2fa046b2ba116700facef4f3b34d9c4fb800a3b828481b8da76037
Contents?: true
Size: 517 Bytes
Versions: 254
Compression:
Stored size: 517 Bytes
Contents
case class PalindromeProducts(minFactor: Int, maxFactor: Int) { lazy val (smallest: (Int, Set[(Int, Int)]), largest: (Int, Set[(Int, Int)])) = { val palindromes = for (a <- Range(minFactor, maxFactor + 1); b <- Range(a, maxFactor + 1) if isPalindrome(a * b)) yield (a * b, (a, b)) val mapped = palindromes.groupBy(_._1).map{case(k, v) => (k, v.map(_._2).toSet)} (mapped.minBy(_._1), mapped.maxBy(_._1)) } private def isPalindrome(i: Int) = i.toString == i.toString.reverse }
Version data entries
254 entries across 254 versions & 1 rubygems