From 060f39f0c1709690ebc447928dcc188be341d1d8 Mon Sep 17 00:00:00 2001 From: "E. Choroba" Date: Mon, 23 Sep 2019 01:11:24 +0200 Subject: Optimize E. Choroba's solution to Stones and Jewels --- challenge-026/e-choroba/perl5/ch-1.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/challenge-026/e-choroba/perl5/ch-1.pl b/challenge-026/e-choroba/perl5/ch-1.pl index 221d562b1c..a09275265b 100755 --- a/challenge-026/e-choroba/perl5/ch-1.pl +++ b/challenge-026/e-choroba/perl5/ch-1.pl @@ -7,8 +7,8 @@ use List::Util qw{ uniq }; sub count { my %args = @_; my $count = 0; - $count += () = $args{jewels} =~ /$_/g for uniq(split //, $args{stones}); - $count + $count += () = $args{jewels} =~ /[$args{stones}]/g; + return $count } use Test::More tests => 6; -- cgit