Skip to content

Instantly share code, notes, and snippets.

@kiritsuku
Created November 13, 2012 12:44
Show Gist options
  • Select an option

  • Save kiritsuku/4065585 to your computer and use it in GitHub Desktop.

Select an option

Save kiritsuku/4065585 to your computer and use it in GitHub Desktop.
project euler problem 32
def p32 = {
def hasAllDigits(str: String) =
str.length == 9 && str.sorted == "123456789"
def multiplicants(x: Int) =
(2 to math.sqrt(x).toInt) filter (x%_ == 0)
def isPandigital(x: Int) =
multiplicants(x) exists (p => hasAllDigits(s"$p$x${x/p}"))
val products = (100 until 10000).par filter isPandigital
products.sum
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment