From bd7154d608ac663d3c8dccaa3ecb629c2ea9b407 Mon Sep 17 00:00:00 2001 From: Andreas Mahnke Date: Mon, 18 Aug 2025 14:17:48 +0200 Subject: optimization --- challenge-335/mahnkong/perl/ch-1.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/challenge-335/mahnkong/perl/ch-1.pl b/challenge-335/mahnkong/perl/ch-1.pl index 4a7e42509a..31ee2ef606 100644 --- a/challenge-335/mahnkong/perl/ch-1.pl +++ b/challenge-335/mahnkong/perl/ch-1.pl @@ -4,7 +4,7 @@ use feature 'signatures'; use Test::More 'no_plan'; sub run(@words) { - return undef unless scalar(@words); + return undef if scalar(@words) < 2; my %occurences; my @result; @@ -12,7 +12,7 @@ sub run(@words) { foreach my $c (split //, $words[0]) { if (! exists($occurences{$c})) { my $max_occurences_all; - foreach my $word (@words) { + foreach my $word (@words[1 .. $#words]) { my $occurences = () = $word =~ /$c/gi; $max_occurences_all = $occurences if (!defined $max_occurences_all || $max_occurences_all > $occurences); } -- cgit