First commit
This commit is contained in:
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
|
||||
|
||||
while(<>) {
|
||||
chomp;
|
||||
/^\D*(\d)(?:\D*(\d))?\D*$/ or die "no head";
|
||||
$sum += "$1" . ($2 || $1);
|
||||
}
|
||||
print "$sum\n";
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
|
||||
my %conv = (one => 1, two => 2, three => 3
|
||||
,four => 4, five => 5, six => 6
|
||||
,seven => 7, eight => 8, nine => 9);
|
||||
|
||||
my $re = "\\d|" . join '|', keys %conv;
|
||||
my $sum = 0;
|
||||
|
||||
while(<>) {
|
||||
chomp;
|
||||
/($re)/ or die "no head";
|
||||
my $start = $conv{$1} || $1;
|
||||
/.*($re)/ or die "no tail";
|
||||
my $end = $conv{$1} || $1;
|
||||
$sum += "$start$end";
|
||||
}
|
||||
print "$sum\n";
|
||||
+1000
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user