Created
November 13, 2012 12:44
-
-
Save kiritsuku/4065585 to your computer and use it in GitHub Desktop.
project euler problem 32
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
| 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