blob: 7c87461f593e9849c607e5276558631ad85f3274 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
use strict;
use warnings;
use Smart::Comments;
use DDP;
use List::Util 'sum';
my $batch;
{
local $/;
open my $fh, '<', "input" or die "no input present, $!";
$batch = <$fh>;
}
my $total_yes = 0;
while ($batch =~ m/((?:[^\n][\n]?)+)/gm ) {
my $group_answers = $1;
chomp $group_answers;
my %counts;
while ($group_answers =~ m/^(\w+)$/mg) {
my $person_answers = $1;
$counts{$_} = 1 for split(//, $person_answers);
}
# p %counts;
$total_yes += sum values %counts
}
print $total_yes;
|