Skip to content

Instantly share code, notes, and snippets.

Created July 16, 2013 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/6009717 to your computer and use it in GitHub Desktop.
Save anonymous/6009717 to your computer and use it in GitHub Desktop.
ABCDABCDABCD
AAABBBCCCDDD
use strict;
use warnings;
use Data::Dumper;
use List::Util qw(reduce);
use File::Slurp qw(read_file);
my $score = reduce { our($a, $b); $a->{$b} += 1; $a } {}, grep /[ABCD]/,split('',read_file("./input.txt"));
print Dumper($score);
__END__
$VAR1 = {
'A' => 6,
'D' => 6,
'C' => 6,
'B' => 6
};
bash$ grep -o . input.txt | sort | uniq -c
6 A
6 B
6 C
6 D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment