Created
January 5, 2013 07:40
-
-
Save kazua/4460374 to your computer and use it in GitHub Desktop.
Project Euler Problem 24
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
| //http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2024 | |
| //K.A | |
| object problem24 { | |
| def getPermNum(sn : String, cnt : Int) : String = { | |
| val bn = sn.toList.map(_.toString.toInt).filter(_ != 0).product | |
| sn.toList.permutations.filter(_.mkString.take(1) == (cnt / bn).toString).take(cnt % bn).map(_.mkString).toList.reverse.head | |
| } | |
| def main(args : Array[String]) { | |
| val cnt = 1000000 | |
| val srcNum = "0123456789" | |
| println(getPermNum(srcNum, cnt)) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment