18 lines
350 B
Perl
Executable File
18 lines
350 B
Perl
Executable File
#!/usr/bin/perl
|
|
use strict;
|
|
my $points = 0;
|
|
|
|
while(<>) {
|
|
my $card = 0;
|
|
my %win;
|
|
my ($id, $win, $choice) = /Card\s+(\d+):([^|]+)[|](.*)/ or die "Bad line: $_\n";
|
|
$win{+$&} = 1 while $win =~ /\d+/g;
|
|
while ($choice =~ /\d+/g) {
|
|
if ($win{+$&}) {
|
|
if ($card) { $card *= 2 } else { $card = 1 }
|
|
}
|
|
}
|
|
$points += $card;
|
|
}
|
|
print "$points\n";
|