Advertisement
musifter

AoC 2022, day 1 (Perl)

Dec 1st, 2022 (edited)
1,216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.19 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use v5.12;
  4. use List::Util  qw(sum);
  5.  
  6. $/ = '';
  7.  
  8. my @elf_cal = sort {$b <=> $a} map { sum split } <>;
  9.  
  10. say "Part 1: ", $elf_cal[0];
  11. say "Part 2: ", sum @elf_cal[0 .. 2];
  12.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement