Created
February 8, 2017 23:37
-
-
Save ken-master/9b47bb3d7c7c6a9e6d3a4fd80165c382 to your computer and use it in GitHub Desktop.
some codility challenge
This file contains 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 | |
function solution($A) { | |
// write your code in PHP7.0 | |
$a = 0; | |
$c = count($A); | |
for( $i = 0; $i <= $c; $i++ ){ | |
if( $A[$i] <= ( current($A) + 1 ) ){ | |
$a++; | |
} | |
} | |
//need to satify the test by output of 3; | |
return $a; | |
} | |
$A = [1, 3, 2, 2, 2, 2, 3, 6, 5, 5, 5, 8, 9, 10]; | |
echo "<pre>"; | |
print_r(solution($A)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment