Created
November 21, 2013 11:37
-
-
Save kazua/7580131 to your computer and use it in GitHub Desktop.
Project Euler Problem 112(別バージョン)
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%20112 | |
| //write kazua | |
| object problem112another { | |
| def ckBouncy(n : Int) = n.toString.toList.sortWith(_ < _).mkString.toInt != n && n.toString.toList.sortWith(_ > _).mkString.toInt != n | |
| def problem112(i : Int = 538, b : Int = 269) : Int = (b.toDouble / i.toDouble * 100).toInt match { | |
| case n if n < 99 => if (ckBouncy(i)) problem112(i + 1, b + 1) else problem112(i + 1, b) | |
| case n => i | |
| } | |
| def main(args : Array[String]) { | |
| println(problem112()) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment