musifter

AoC 2025, day 6 part 1 (Perl)

Dec 6th, 2025 (edited)
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.32 KB | Source Code | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. use feature         qw(say);
  7. use List::Util      qw(sum product zip);
  8.  
  9. my @input = map { [m#[^\s]+#g] } <>;
  10. my @ops   = @{pop @input};
  11.  
  12. my $part1 = 0;
  13. foreach my $col (zip @input) {
  14.     $part1 += (shift @ops eq '+') ? sum @$col : product @$col;
  15. }
  16.  
  17. say "Part 1: $part1";
Advertisement
Add Comment
Please, Sign In to add comment