18 lines
453 B
PHP
18 lines
453 B
PHP
<?php
|
|
/**
|
|
*
|
|
*/
|
|
|
|
$input = file('input', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
|
$input = array_map('intval', $input);
|
|
|
|
$increased = 0;
|
|
$previousReading = array_sum(array_slice($input, 0, 3));
|
|
for ($i = 1; $i < count($input) - 2; $i++) {
|
|
$currentReading = array_sum(array_slice($input, $i, 3));
|
|
if ($currentReading > $previousReading) {
|
|
$increased++;
|
|
}
|
|
$previousReading = $currentReading;
|
|
}
|
|
echo $increased; // 1597
|