diff --git a/EquilibriumIndex.php b/EquilibriumIndex.php index 020dd2b..a057a54 100644 --- a/EquilibriumIndex.php +++ b/EquilibriumIndex.php @@ -1,9 +1,49 @@ $i; $y--) { + $high += $arr[$y]; + echo "high: $y\n"; + } + + # Checks if the sum of the high numbers is equal to the sum of the low numbers. If the sums are equal - the current index is confirmed as an equilibrium index. + if($high === $low) { + array_push($output,$i); + } + } + + # Prints message if no equilibrium indices are found + if(count($output) == 0) { + echo "\nNo equilibrium indices found"; + return; + } + return $output; } - + +?>