3rd and 2nd day

This commit is contained in:
kplaczek committed 2021-12-03 19:25:51 +01:00
1 parent 1e900f4642
commit 6365d1fef7
9 files changed
+2103 -2017

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
<?php
$increased = 0;
$inputStream = fopen('input', 'r');
$horizontal = $depth = 0;
while (($line = fgets($inputStream)) !== false) {
[$instruction, $value] = explode(' ', trim($line));
match ($instruction) {
'down' => $depth += (int)$value,
'up' => $depth -= (int)$value,
'forward' => $horizontal += (int)$value,
};
}
echo $depth * $horizontal; // 1635930