diff options
| author | Aaron Smith <asmith@sumologic.com> | 2021-01-22 20:30:29 -0600 |
|---|---|---|
| committer | Aaron Smith <asmith@sumologic.com> | 2021-01-22 20:30:29 -0600 |
| commit | f3397b7c8b0dcb3c5bac65d5f3fbd18cbfeea208 (patch) | |
| tree | 3dc95a33d1bde6763a45ad8d6c232c98e509c8f1 /challenge-096/aaronreidsmith | |
| parent | 754e6dcd79dde5387229a23ae7eca35d70eac4a3 (diff) | |
| download | perlweeklychallenge-club-f3397b7c8b0dcb3c5bac65d5f3fbd18cbfeea208.tar.gz perlweeklychallenge-club-f3397b7c8b0dcb3c5bac65d5f3fbd18cbfeea208.tar.bz2 perlweeklychallenge-club-f3397b7c8b0dcb3c5bac65d5f3fbd18cbfeea208.zip | |
Challenge 96 - Raku
Diffstat (limited to 'challenge-096/aaronreidsmith')
| -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..31d44ad0a0 --- /dev/null +++ b/challenge-096/aaronreidsmith/blog.txt @@ -0,0 +1 @@ +https://aaronreidsmith.github.io/blog/perl-weekly-chellanege-096/ 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..d38a8c5516 --- /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; +}
\ No newline at end of file |
