blob: 66e423a64cf85c43d14dcd3fb0386f86136fa03e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
use strict;
use warnings;
my ($depth, $pos) = (0, 0);
while (<>) {
if (/forward (\d+)/) {
$pos += $1;
} elsif (/down (\d+)/) {
$depth += $1;
} elsif (/up (\d+)/) {
$depth -= $1;
}
}
print $depth * $pos, "\n";
|