Created
January 10, 2017 16:56
-
-
Save foooomio/04376c912583c9b1889189bc535f5067 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val answers = Iterator.from(10, 1).filter( | |
Foo(_).test(isPalindrome) | |
) | |
println(answers.next) | |
def isPalindrome(base: String): Boolean = | |
base == base.reverse | |
case class Foo(n: Integer) { | |
lazy val decimal: String = Integer.toString(n) | |
lazy val octal: String = Integer.toOctalString(n) | |
lazy val binary: String = Integer.toBinaryString(n) | |
def test(f: String => Boolean): Boolean = | |
f(decimal) && f(octal) && f(binary) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment