News for hackers. Stuff that matters.
Re:Show HN: PyBites Code Challenges by rurban on Monday January 09, 2017 @06:21AM (#13355537)
This would be the readable perl5 solution:

    my %scrabble_scores = (
       1 => [qw( E A O I N R T L S U )], 
       2 => [qw( D G )],
       3 => [qw( B C M P )],
       4 => [qw( F H V W Y )],
       5 => [qw( K )],
       8 => [qw( J X )],
      10 => [qw( Q Z )]);
    my $dict = "/usr/share/dict/words";
    open my $d, "<", $dict or die "$dict: $!";
    
    keys my %a = 26; # ranked alphabet
    for my $rank (keys %scrabble_scores) {
      for my $letter (@{$scrabble_scores{$rank}}) {
        $a{$letter} = $rank;
      }
    }
    
    my @maxscore = ('' => 0);
    while (<$d>) {
      my $score = 0;
      chomp;
      for my $c (split//) {
        $score += $a{uc($c)};
      }
      @maxscore = ($_ => $score) if $score > $maxscore[1];
    }
    print "$maxscore[0] => $maxscore[1]\n";
Arguable more readable than python

There are no comments on this comment yet.