18 lines
492 B
PHP
18 lines
492 B
PHP
|
<?php
|
||
|
|
||
|
$elves = explode("\n", file_get_contents('./input.txt'));
|
||
|
|
||
|
echo count(
|
||
|
array_filter(
|
||
|
$elves,
|
||
|
static function($elf) {
|
||
|
[$section1, $section2] = array_map(static fn($section) => explode('-', $section), explode(',', $elf));
|
||
|
return
|
||
|
($section2[0] >= $section1[0] && $section2[1] <= $section1[1])
|
||
|
||
|
||
|
($section1[0] >= $section2[0] && $section1[1] <= $section2[1])
|
||
|
;
|
||
|
}
|
||
|
)
|
||
|
);
|