closedPaths Problem in PHP
function closedPaths($number) {
$sum = 0;
for($a=0;$a<strlen($number);$a++){
$ch = (string)$number;
$xnum = $ch[$a];
if($xnum==0||$xnum==4||$xnum==6||$xnum==9){
$sum++;
// print "$xnum 1<br>";
}
if($xnum==8){
$sum=$sum+2;
// print "$xnum 2<br>";
}
}
return $sum;
}
Comments