]> www.fi.muni.cz Git - aoc2020.git/blob - 3.pl
Task 9 Perl Golf-style
[aoc2020.git] / 3.pl
1 #!/usr/bin/perl -w
2
3 use strict;
4
5 my $count = 0;
6
7 while (<>) {
8         my ($min, $max, $letter, $pass) = /\A(\d+)-(\d+)\s+(\S):\s+(\S+)\s*\z/;
9         if (!defined $pass) {
10                 print "Divny radek $_\n";
11                 next;
12         }
13
14         
15         my $chars =()= ($pass =~ /$letter/g);
16
17         # print "$min-$max $letter: [$pass] - $chars\n";
18         $count++ if $chars >= $min && $chars <= $max;
19 }
20
21 print $count, "\n";
22