Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use feature qw(say);
- use List::Util qw(sum product zip);
- my @input = map { [m#[^\s]+#g] } <>;
- my @ops = @{pop @input};
- my $part1 = 0;
- foreach my $col (zip @input) {
- $part1 += (shift @ops eq '+') ? sum @$col : product @$col;
- }
- say "Part 1: $part1";
Advertisement
Add Comment
Please, Sign In to add comment