diff options
| -rw-r--r-- | challenge-096/aaronreidsmith/blog.txt | 1 | ||||
| -rw-r--r-- | challenge-096/aaronreidsmith/raku/ch-1.raku | 24 | ||||
| -rw-r--r-- | challenge-096/aaronreidsmith/raku/ch-2.raku | 28 |
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; +} |
