This commit is contained in:
Yanick Champoux 2017-12-05 15:12:32 -05:00
parent 424e0310af
commit 592efaf1af
3 changed files with 41 additions and 0 deletions

20
2015/12/a.pl Normal file
View File

@ -0,0 +1,20 @@
use 5.20.0;
use List::AllUtils qw/ sum /;
use File::Serialize;
use experimental 'signatures', 'smartmatch';
my $data = deserialize_file shift;
say add($data);
sub add($data) {
given ( ref $data ) {
return sum map { add($_) } @$data when 'ARRAY';
return sum map { add($_) } values %$data when 'HASH';
default { return 0 + $data };
}
}

20
2015/12/b.pl Normal file
View File

@ -0,0 +1,20 @@
use 5.20.0;
use List::AllUtils qw/ sum /;
use File::Serialize;
use experimental 'signatures', 'smartmatch';
my $data = deserialize_file shift;
say add($data);
sub add($data) {
given ( ref $data ) {
return sum map { add($_) } @$data when 'ARRAY';
return ( ( grep { $_ eq 'red' } values %$data ) ? 0 : 1) * sum map { add($_) } values %$data when 'HASH';
default { return 0 + $data };
}
}

1
2015/12/input.json Normal file

File diff suppressed because one or more lines are too long