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; + } + ) +);