Created
November 19, 2013 21:08
-
-
Save kazua/7552620 to your computer and use it in GitHub Desktop.
Project Euler Problem 112(PHP)
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
| <?php | |
| //http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%20112 | |
| //write kazua | |
| function ckBouncy($n) { | |
| if (strspn($n, "0123456789") != strlen($n)) return false; | |
| $k = $z = $g = str_split($n); | |
| sort($z); | |
| rsort($g); | |
| $r = ($k != $z) && ($k != $g); | |
| unset($k,$z,$g); | |
| gc_collect_cycles(); | |
| return $r; | |
| } | |
| function problem112($i = 538, $b = 269) { | |
| for (; $b / $i * 100 < 99; $i++) if (ckBouncy($i)) $b++; | |
| return $i; | |
| } | |
| echo problem112(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment