aboutsummaryrefslogtreecommitdiff
path: root/challenge-026
diff options
context:
space:
mode:
authorJoelle Maslak <jmaslak@antelope.net>2019-09-20 16:29:09 -0700
committerJoelle Maslak <jmaslak@antelope.net>2019-09-20 16:29:09 -0700
commit6f2e7e09ebfb8b82a6e0151ba5b645f91488d202 (patch)
treec29904138f4ba44cb8d11e337dd7cad2fc9c7059 /challenge-026
parent46742d04f0c11a82dd4db224590380788c05b15e (diff)
downloadperlweeklychallenge-club-6f2e7e09ebfb8b82a6e0151ba5b645f91488d202.tar.gz
perlweeklychallenge-club-6f2e7e09ebfb8b82a6e0151ba5b645f91488d202.tar.bz2
perlweeklychallenge-club-6f2e7e09ebfb8b82a6e0151ba5b645f91488d202.zip
Joelle's solutions to 26.1 in P6 & P5
Diffstat (limited to 'challenge-026')
-rwxr-xr-xchallenge-026/joelle-maslak/perl5/ch-1.pl12
-rwxr-xr-xchallenge-026/joelle-maslak/perl6/ch-1.p610
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;
+}
+
+