diff options
| author | Matthias Muth <matthias.muth@gmx.de> | 2023-03-05 23:08:10 +0100 |
|---|---|---|
| committer | Matthias Muth <matthias.muth@gmx.de> | 2023-03-05 23:08:10 +0100 |
| commit | f0ddda5e8279ef26cbc398788c8fefc5c0e2ccaa (patch) | |
| tree | fc35a6ed2c64d5e3112ae5ed9466dd49850547d3 | |
| parent | 0bd4f12a8208ea9030382b703cc53556d2ed03c5 (diff) | |
| download | perlweeklychallenge-club-f0ddda5e8279ef26cbc398788c8fefc5c0e2ccaa.tar.gz perlweeklychallenge-club-f0ddda5e8279ef26cbc398788c8fefc5c0e2ccaa.tar.bz2 perlweeklychallenge-club-f0ddda5e8279ef26cbc398788c8fefc5c0e2ccaa.zip | |
Cosmetic changes.
| -rwxr-xr-x | challenge-206/matthias-muth/perl/ch-1.pl | 2 | ||||
| -rwxr-xr-x | challenge-206/matthias-muth/perl/ch-2.pl | 9 |
2 files changed, 6 insertions, 5 deletions
diff --git a/challenge-206/matthias-muth/perl/ch-1.pl b/challenge-206/matthias-muth/perl/ch-1.pl index a23923ea9f..5553b96208 100755 --- a/challenge-206/matthias-muth/perl/ch-1.pl +++ b/challenge-206/matthias-muth/perl/ch-1.pl @@ -8,7 +8,7 @@ no warnings 'experimental::signatures'; use List::Util qw( min ); sub time_diffs( $fixed, @others ) { - # Return all differences between one fixed timestamp and a list of others. + # Return all differences between one timestamp and a list of others. # Use the time difference spanning over midnight if it is shorter # (by simply using the minimum of both). return diff --git a/challenge-206/matthias-muth/perl/ch-2.pl b/challenge-206/matthias-muth/perl/ch-2.pl index 76758886f5..80dc03e7c0 100755 --- a/challenge-206/matthias-muth/perl/ch-2.pl +++ b/challenge-206/matthias-muth/perl/ch-2.pl @@ -6,8 +6,6 @@ use warnings; use feature 'signatures'; no warnings 'experimental::signatures'; -use List::Util qw( min max sum ); - sub permute( $a_ref ) { return undef unless defined $a_ref && ref $a_ref eq 'ARRAY'; return () if @$a_ref == 0; @@ -23,11 +21,14 @@ sub permute( $a_ref ) { return @permutations; } +use List::Util qw( min max sum ); + sub sum_of_min_of_pairs( @a ) { return undef unless @a % 2 == 0; - return - sum( map $_ % 2 == 0 ? min( $a[$_], $a[ $_ + 1 ] ) : 0, 0 .. $#a - 1 ); + return sum( + map $_ % 2 == 0 ? min( $a[$_], $a[ $_ + 1 ] ) : 0, 0..( $#a - 1 ) + ); } sub max_of_sums( @a ) { |
