28 lines
503 B
PHP
Executable File
28 lines
503 B
PHP
Executable File
#!/usr/bin/env php
|
|
<?php
|
|
|
|
$lines = explode("\n", file_get_contents("input"));
|
|
|
|
$number = 248131121;
|
|
|
|
$sum = 0;
|
|
$start = 0;
|
|
|
|
for($i=0; $i<count($lines); $i++) {
|
|
$sum += intval($lines[$i]);
|
|
|
|
while($sum > $number)
|
|
$sum -= $lines[$start++];
|
|
|
|
if($sum === $number)
|
|
break;
|
|
}
|
|
|
|
$subset = array_slice($lines, $start, $i - $start);
|
|
sort($subset);
|
|
|
|
echo "Range starts on $start and ends on $i.\n";
|
|
echo "Lowest {$subset[0]} and highest " . array_pop($subset) . "\n";
|
|
echo "(you can sum them yourself)\n";
|
|
?>
|