18 lines
385 B
PHP
18 lines
385 B
PHP
|
<?php
|
||
|
|
||
|
$numbers = array_map('intval', explode("\n", file_get_contents('input.txt')));
|
||
|
|
||
|
$current_slice = array_sum(array_slice($numbers, 0, 3));
|
||
|
|
||
|
$count = 0;
|
||
|
|
||
|
for ($i = 1, $l = count($numbers) - 3; $i <= $l; $i++) {
|
||
|
$new_slice = array_sum(array_slice($numbers, $i, 3));
|
||
|
if ($new_slice > $current_slice) {
|
||
|
$count++;
|
||
|
}
|
||
|
|
||
|
$current_slice = $new_slice;
|
||
|
}
|
||
|
|
||
|
echo $count;
|