aoc

Advent of Code Solutions
git clone git://git.alexkarle.com.com/aoc
Log | Files | Refs | README | LICENSE

sol2.pl (312B) [raw]


      1 #!/usr/bin/env perl
      2 use strict;
      3 use warnings;
      4 
      5 open(my $fh, '<', 'input') or die "$!";
      6 my $n;
      7 for my $line (<$fh>) {
      8     my ($A, $B, $goal, $pass) = $line =~ m{^(\d+)-(\d+) ([a-z]): ([a-z]+)};
      9     if ((substr($pass, $A-1, 1) eq $goal) xor (substr($pass, $B-1, 1) eq $goal)) {
     10         $n++;
     11     }
     12 }
     13 print "$n\n";