26 lines
411 B
Perl
26 lines
411 B
Perl
|
use lib qw/ . /;
|
||
|
|
||
|
use Part1;
|
||
|
|
||
|
package Day2::Part2;
|
||
|
|
||
|
use 5.36.0;
|
||
|
|
||
|
use List::Util qw/ sum pairmap /;
|
||
|
use List::MoreUtils qw/ part zip /;
|
||
|
|
||
|
sub is_safe_dampened(@report) {
|
||
|
for my $i ( 0..$#report) {
|
||
|
my @copy = @report;
|
||
|
splice @copy, $i, 1;
|
||
|
return 1 if Day2::Part1::is_safe(@copy);
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
sub solve(@reports) {
|
||
|
return sum map { is_safe_dampened(@$_) } @reports;
|
||
|
}
|
||
|
|
||
|
1;
|