blob: 57b586c7d9eabde00c087730e50b95b66da20762 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
use strict;
use warnings;
my $points = 0;
while (<>) {
chomp;
$_ =~ s/Card (\d+): //;
my ($winning, $mine) = split(/ [|] /);
my %winning = map {$_ => 1} split(/ +/, $winning);
my @mine = split(/ +/, $mine);
my $score = 0;
for (@mine) {
$score = ($score ? $score * 2 : 1) if exists $winning{$_};
}
$points += $score;
}
print $points, "\n";
|