From 6f2e7e09ebfb8b82a6e0151ba5b645f91488d202 Mon Sep 17 00:00:00 2001 From: Joelle Maslak Date: Fri, 20 Sep 2019 16:29:09 -0700 Subject: Joelle's solutions to 26.1 in P6 & P5 --- challenge-026/joelle-maslak/perl5/ch-1.pl | 12 ++++++++++++ challenge-026/joelle-maslak/perl6/ch-1.p6 | 10 ++++++++++ 2 files changed, 22 insertions(+) create mode 100755 challenge-026/joelle-maslak/perl5/ch-1.pl create mode 100755 challenge-026/joelle-maslak/perl6/ch-1.p6 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; +} + + -- cgit