aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark <53903062+andemark@users.noreply.github.com>2023-08-02 10:29:43 +0000
committerMark <53903062+andemark@users.noreply.github.com>2023-08-02 10:29:43 +0000
commit5e43c4f39c15b90ee1fd43b314d12472bc066587 (patch)
tree4910a36ad57665cacd544c7c10793124c40c4d68
parent634e3f9f3b2868c9fb908dd5984dc14a6591262d (diff)
downloadperlweeklychallenge-club-5e43c4f39c15b90ee1fd43b314d12472bc066587.tar.gz
perlweeklychallenge-club-5e43c4f39c15b90ee1fd43b314d12472bc066587.tar.bz2
perlweeklychallenge-club-5e43c4f39c15b90ee1fd43b314d12472bc066587.zip
Challenge 228 Solutions (Perl)
-rw-r--r--challenge-228/mark-anderson/perl/ch-2.pl8
1 files changed, 4 insertions, 4 deletions
diff --git a/challenge-228/mark-anderson/perl/ch-2.pl b/challenge-228/mark-anderson/perl/ch-2.pl
index 8f20366521..f5be9a5542 100644
--- a/challenge-228/mark-anderson/perl/ch-2.pl
+++ b/challenge-228/mark-anderson/perl/ch-2.pl
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
use v5.32;
-use List::Util qw/min sum/;
+use List::Util qw/min/;
use List::MoreUtils qw/first_index/;
use Test::More;
use experimental qw/signatures/;
@@ -12,14 +12,14 @@ done_testing;
sub empty_array(@a)
{
- my @r;
+ my $total;
while(@a)
{
my $i = first_index { $_ == min @a } @a;
@a = (@a[$i+1..$#a], @a[0..$i-1]);
- push @r, $i+1;
+ $total += $i+1
}
- sum @r
+ $total
}