Solution to the first puzzle of Advent of Code 2021. pog
This commit is contained in:
17
01/index.php
Normal file
17
01/index.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
$increased = 0;
|
||||
$inputStream = fopen('input', 'r');
|
||||
$previousReading = (int)fgets($inputStream);
|
||||
while (($line = fgets($inputStream)) !== false) {
|
||||
$line = (int)$line;
|
||||
if ($line > $previousReading) {
|
||||
$increased++;
|
||||
}
|
||||
$previousReading = $line;
|
||||
}
|
||||
fclose($inputStream);
|
||||
echo $increased; //1553
|
||||
Reference in New Issue
Block a user