diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2019-09-21 10:32:29 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-21 10:32:29 +0100 |
| commit | 91d089d0119dcc0afe06c6fe43bfe941ba8a5bd5 (patch) | |
| tree | e8afc31256172bb1afbe95cd32fdf5ce1ad04f2a | |
| parent | 8b937b8628ed26da2d72180ba8ea9b37f5bfce6f (diff) | |
| parent | 6f2e7e09ebfb8b82a6e0151ba5b645f91488d202 (diff) | |
| download | perlweeklychallenge-club-91d089d0119dcc0afe06c6fe43bfe941ba8a5bd5.tar.gz perlweeklychallenge-club-91d089d0119dcc0afe06c6fe43bfe941ba8a5bd5.tar.bz2 perlweeklychallenge-club-91d089d0119dcc0afe06c6fe43bfe941ba8a5bd5.zip | |
Merge pull request #647 from jmaslak/joelle-26-1-1
Joelle's solutions to 26.1 in P6 & P5
| -rwxr-xr-x | challenge-026/joelle-maslak/perl5/ch-1.pl | 12 | ||||
| -rwxr-xr-x | challenge-026/joelle-maslak/perl6/ch-1.p6 | 10 |
2 files changed, 22 insertions, 0 deletions
diff --git a/challenge-026/joelle-maslak/perl5/ch-1.pl b/challenge-026/joelle-maslak/perl5/ch-1.pl new file mode 100755 index 0000000000..1e472dbbec --- /dev/null +++ b/challenge-026/joelle-maslak/perl5/ch-1.pl @@ -0,0 +1,12 @@ +#!/usr/bin/env perl + +use v5.16; +use strict; +use warnings; + +die("Provide (only) stones and jewels") unless @ARGV == 2; + +my (%hash) = map { $_, 1 } split //, $ARGV[0]; +my (@matches) = grep { exists $hash{$_} } split //, $ARGV[1]; +say scalar(@matches); + diff --git a/challenge-026/joelle-maslak/perl6/ch-1.p6 b/challenge-026/joelle-maslak/perl6/ch-1.p6 new file mode 100755 index 0000000000..b384931266 --- /dev/null +++ b/challenge-026/joelle-maslak/perl6/ch-1.p6 @@ -0,0 +1,10 @@ +#!/usr/bin/env perl6 +use v6; + +sub MAIN(Str:D $stones, Str:D $jewels) { + my $stone-set = $stones.comb.cache; + my $matches = $jewels.comb.grep: { $^a ∈ $stone-set }; + say $matches.elems; +} + + |
