Advertisement
musifter

AoC 2024, day 3, part 1 (Perl)

Dec 2nd, 2024
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.22 KB | Source Code | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. use feature         qw(say);
  7.  
  8. my $part1 = 0;
  9. foreach my $line (<>) {
  10.     $part1 += $1 * $2  while ($line =~ m#mul\((\d{1,3}),(\d{1,3})\)#g);
  11. }
  12.  
  13. say "Part 1: ", $part1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement