commit 7a976d845a8737b985b72938968770ae789f2118
parent 78973c0984220bb945912faf993edf0f149c359d
Author: Samir Parikh <noreply@samirparikh.com>
Date: Sat, 5 Nov 2022 15:36:59 +0000
solve part 2 of day13
Diffstat:
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/day13/Day13.pm b/day13/Day13.pm
@@ -8,9 +8,9 @@ use List::Util qw( max );
use Algorithm::Permute;
our @EXPORT = qw( calc_tot_hap_chg );
-my @answers;
sub calc_tot_hap_chg {
+ my @answers;
my @people = @{ $_[0] };
my %hap_units = %{ $_[1] };
Algorithm::Permute::permute {
diff --git a/day13/day13.pl b/day13/day13.pl
@@ -23,4 +23,12 @@ foreach ( @deltas ) {
my @people = sort keys %people;
say "part 1: ", calc_tot_hap_chg( \@people, \%hap_units );
-#say "part 2: ";
+
+foreach my $person ( @people ) {
+ $hap_units{ me }{ $person } = 0;
+ $hap_units{ $person }{ me } = 0;
+}
+
+push @people => 'me';
+
+say "part 2: ", calc_tot_hap_chg( \@people, \%hap_units );