From 155c2905a86641f807ebf318f2cd6f2168072b9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Thu, 3 Dec 2020 12:28:02 +0100 Subject: [PATCH] :sparkles: Finit le 3eme jour --- day_3/part_1.php | 29 +++++++++++++++++++++++++++++ day_3/part_2.php | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 day_3/part_1.php create mode 100644 day_3/part_2.php diff --git a/day_3/part_1.php b/day_3/part_1.php new file mode 100644 index 0000000..85144fe --- /dev/null +++ b/day_3/part_1.php @@ -0,0 +1,29 @@ + 1, 'down' => 1], + ['Right' => 3, 'down' => 1], + ['Right' => 5, 'down' => 1], + ['Right' => 7, 'down' => 1], + ['Right' => 1, 'down' => 2], +]; + +$result = 1; +foreach ($tests as $i => $test) { + $right = 0; + $down = 0; + $count_trees = 0; + while ($right < $length && $down < $height) { + if ($map[$down][$right] === '#') { + $count_trees++; + } + + $right += $test['Right']; + $down += $test['down']; + } + +// echo sprintf('Trouvé %u arbres sur le parcours %u', $count_trees, $i); + $result *= $count_trees; +} + + +echo $result; \ No newline at end of file