advent_of_code_2022/day_1/part_2.php

12 lines
209 B
PHP
Raw Normal View History

<?php
$calories = array_map(
static fn($elf) => array_sum(explode("\n", $elf)),
explode("\n\n", file_get_contents('./input.txt'))
);
rsort($calories);
echo array_sum(array_slice($calories, 0, 3));