From f0609cd245d65c4d698aab46a1f06eccd1b99603 Mon Sep 17 00:00:00 2001 From: Clement Desmidt Date: Tue, 6 Dec 2022 10:12:35 +0100 Subject: [PATCH] :sparkles: Finit le jour 4 --- day_4/part_1.php | 17 +++++++++++++++++ day_4/part_2.php | 15 +++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 day_4/part_1.php create mode 100644 day_4/part_2.php diff --git a/day_4/part_1.php b/day_4/part_1.php new file mode 100644 index 0000000..7d6718f --- /dev/null +++ b/day_4/part_1.php @@ -0,0 +1,17 @@ + explode('-', $section), explode(',', $elf)); + return + ($section2[0] >= $section1[0] && $section2[1] <= $section1[1]) + || + ($section1[0] >= $section2[0] && $section1[1] <= $section2[1]) + ; + } + ) +); diff --git a/day_4/part_2.php b/day_4/part_2.php new file mode 100644 index 0000000..38c2c2f --- /dev/null +++ b/day_4/part_2.php @@ -0,0 +1,15 @@ + explode('-', $section), explode(',', $elf)); + return count( + array_intersect(range($section1[0], $section1[1]), range($section2[0], $section2[1])) + ) > 0; + } + ) +);