aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Proctor <simon.proctor@zoopla.co.uk>2020-06-11 13:48:52 +0100
committerSimon Proctor <simon.proctor@zoopla.co.uk>2020-06-11 13:48:52 +0100
commitfc87777844819cf04685204088d9d03974aacad4 (patch)
treeb710938beed35a77217dfc120f2feae5d0f7dd31
parent4a7d9c71ac7516dda01631d59845ec03933907be (diff)
downloadperlweeklychallenge-club-fc87777844819cf04685204088d9d03974aacad4.tar.gz
perlweeklychallenge-club-fc87777844819cf04685204088d9d03974aacad4.tar.bz2
perlweeklychallenge-club-fc87777844819cf04685204088d9d03974aacad4.zip
Challenge 2
-rw-r--r--challenge-064/simon-proctor/raku/ch-2.raku13
1 files changed, 13 insertions, 0 deletions
diff --git a/challenge-064/simon-proctor/raku/ch-2.raku b/challenge-064/simon-proctor/raku/ch-2.raku
new file mode 100644
index 0000000000..435ddf90b0
--- /dev/null
+++ b/challenge-064/simon-proctor/raku/ch-2.raku
@@ -0,0 +1,13 @@
+#!/usr/bin/env raku
+
+use v6.d;
+
+#| Given a string and a list of other strings return those in the main string in order
+sub MAIN (
+ Str $haystack, #= Target string to search
+ *@needles #= Strings to search for
+) {
+ my @out = @needles.map( { $_ => $haystack.index($_) } ).grep( { $_.value.defined } ).sort( { $^a.value <=> $^b.value } ).map( *.key );
+ (.say for @out ) if @out;
+ "0".say unless @out;
+}