From c290b5fee6b607214beeb72819b9185a792d6d9a Mon Sep 17 00:00:00 2001 From: Clement Desmidt Date: Thu, 9 Dec 2021 17:31:46 +0100 Subject: [PATCH] =?UTF-8?q?:sparkles:=20Finit=20le=20jour=208=20et=20le=20?= =?UTF-8?q?d=C3=A9but=20du=209?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- day_8/part_1.php | 15 ++++++++ day_8/part_2.php | 99 ++++++++++++++++++++++++++++++++++++++++++++++++ day_9/part_1.php | 31 +++++++++++++++ 3 files changed, 145 insertions(+) create mode 100644 day_8/part_1.php create mode 100644 day_8/part_2.php create mode 100644 day_9/part_1.php diff --git a/day_8/part_1.php b/day_8/part_1.php new file mode 100644 index 0000000..145d9c9 --- /dev/null +++ b/day_8/part_1.php @@ -0,0 +1,15 @@ + $row) { + foreach ($row as $j => $cell) { + $count = 0; + if (!array_key_exists($i - 1, $grid) || $grid[$i - 1][$j] > $cell) { + $count++; + } + if (!array_key_exists($i + 1, $grid) || $grid[$i + 1][$j] > $cell) { + $count++; + } + if (!array_key_exists($j - 1, $row) ||$row[$j - 1] > $cell) { + $count++; + } + if (!array_key_exists($j + 1, $row) || $row[$j + 1] > $cell) { + $count++; + } + + if ($count === 4) { + $low_points[] = (int) $cell; + } + } +} + +echo array_sum($low_points) + count($low_points); \ No newline at end of file