Skip to content

Instantly share code, notes, and snippets.

@foooomio
Created January 10, 2017 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foooomio/04376c912583c9b1889189bc535f5067 to your computer and use it in GitHub Desktop.
Save foooomio/04376c912583c9b1889189bc535f5067 to your computer and use it in GitHub Desktop.
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