Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 25 lines (19 sloc) 0.479 kb
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
use List::Util qw(sum);
use Text::CSV;
sub alpha_value {
my ($letter) = @_;
return ord($letter) - 64;
}
sub score {
my ( $position, $name ) = @_;
return $position * sum map { alpha_value($_) } split( //, $name );
}
my $csv = Text::CSV->new();
open my $fh, '<', 'names.txt' or die $!;
my @names = @{ $csv->getline($fh) };
@names = sort @names;
say sum map { score( $_ + 1, $names[$_] ) } 0 .. $#names;
Jump to Line
Something went wrong with that request. Please try again.