Skip to content

Instantly share code, notes, and snippets.

@ken-master
Created February 8, 2017 23:37
Show Gist options
  • Save ken-master/9b47bb3d7c7c6a9e6d3a4fd80165c382 to your computer and use it in GitHub Desktop.
Save ken-master/9b47bb3d7c7c6a9e6d3a4fd80165c382 to your computer and use it in GitHub Desktop.
some codility challenge
<?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