Created
July 16, 2013 15:21
-
-
Save anonymous/6009717 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ABCDABCDABCD | |
AAABBBCCCDDD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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