aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-01-23 21:49:14 +0000
committerGitHub <noreply@github.com>2021-01-23 21:49:14 +0000
commit024f355cca56ff16d1802f3449292da3717c8b3f (patch)
tree45c234a0093ab740faafc60fe2627d4235515d61
parent8f01c5d2ac87d57cab2d7d14038d1ad33141c114 (diff)
parent039231a412051b974fb688150fa19bca737a4955 (diff)
downloadperlweeklychallenge-club-024f355cca56ff16d1802f3449292da3717c8b3f.tar.gz
perlweeklychallenge-club-024f355cca56ff16d1802f3449292da3717c8b3f.tar.bz2
perlweeklychallenge-club-024f355cca56ff16d1802f3449292da3717c8b3f.zip
Merge pull request #3351 from aaronreidsmith/challenge-096
Challenge 96 - Raku
-rw-r--r--challenge-096/aaronreidsmith/blog.txt1
-rw-r--r--challenge-096/aaronreidsmith/raku/ch-1.raku24
-rw-r--r--challenge-096/aaronreidsmith/raku/ch-2.raku28
3 files changed, 53 insertions, 0 deletions
diff --git a/challenge-096/aaronreidsmith/blog.txt b/challenge-096/aaronreidsmith/blog.txt
new file mode 100644
index 0000000000..1f42919f79
--- /dev/null
+++ b/challenge-096/aaronreidsmith/blog.txt
@@ -0,0 +1 @@
+https://aaronreidsmith.github.io/blog/perl-weekly-challenge-096/ \ No newline at end of file
diff --git a/challenge-096/aaronreidsmith/raku/ch-1.raku b/challenge-096/aaronreidsmith/raku/ch-1.raku
new file mode 100644
index 0000000000..48575db535
--- /dev/null
+++ b/challenge-096/aaronreidsmith/raku/ch-1.raku
@@ -0,0 +1,24 @@
+#!/usr/bin/env raku
+
+sub challenge(Str $S) returns Str {
+ $S.trim.words.reverse.join(' ');
+}
+
+multi sub MAIN(Str $S) {
+ say challenge($S);
+}
+
+multi sub MAIN(Bool :$test) {
+ use Test;
+
+ my @tests = (
+ ('The Weekly Challenge', 'Challenge Weekly The'),
+ (' Perl and Raku are part of the same family ', 'family same the of part are Raku and Perl')
+ );
+
+ for @tests -> ($input, $expected) {
+ is(challenge($input), $expected);
+ }
+
+ done-testing;
+}
diff --git a/challenge-096/aaronreidsmith/raku/ch-2.raku b/challenge-096/aaronreidsmith/raku/ch-2.raku
new file mode 100644
index 0000000000..954ddfc648
--- /dev/null
+++ b/challenge-096/aaronreidsmith/raku/ch-2.raku
@@ -0,0 +1,28 @@
+#!/usr/bin/env raku
+
+use Text::Levenshtein; # imports `distance`
+
+sub challenge(Str $S1, Str $S2) returns Int {
+ distance($S1.lc, $S2.lc).head;
+}
+
+multi sub MAIN(Str $S1, Str $S2) {
+ say challenge($S1, $S2);
+}
+
+multi sub MAIN(Bool :$test) {
+ use Test;
+
+ my @tests = (
+ ('kitten', 'sitting', 3),
+ ('sunday', 'monday', 2),
+ ('SUNDAY', 'sunday', 0),
+ ('female', 'male', 2)
+ );
+
+ for @tests -> ($S1, $S2, $expected) {
+ is(challenge($S1, $S2), $expected);
+ }
+
+ done-testing;
+}