You are viewing a single comment's thread. Return to all comments →
PHP solution
function countApplesAndOranges( int $houseStart, int $houseEnd, int $applePoint, int $orrangePoint, array $apples, array $oranges ) { $getPoints=static function(int $treePoint, array $points) use ($houseStart,$houseEnd) { $res=0; foreach($points as $point) { $fallPoint = $treePoint+$point; if ($fallPoint>=$houseStart && $fallPoint<=$houseEnd) $res++; } return $res; }; foreach([$applePoint=>$apples, $orrangePoint=>$oranges] as $tree=>$fruits) { print($getPoints($tree,$fruits) . "\n"); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Apple and Orange
You are viewing a single comment's thread. Return to all comments →
PHP solution