From f3397b7c8b0dcb3c5bac65d5f3fbd18cbfeea208 Mon Sep 17 00:00:00 2001 From: Aaron Smith Date: Fri, 22 Jan 2021 20:30:29 -0600 Subject: Challenge 96 - Raku --- challenge-096/aaronreidsmith/blog.txt | 1 + challenge-096/aaronreidsmith/raku/ch-1.raku | 24 ++++++++++++++++++++++++ challenge-096/aaronreidsmith/raku/ch-2.raku | 28 ++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 challenge-096/aaronreidsmith/blog.txt create mode 100644 challenge-096/aaronreidsmith/raku/ch-1.raku create mode 100644 challenge-096/aaronreidsmith/raku/ch-2.raku 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 -- cgit From 595f21837542ef72c49a226bb047894a8a7ccd42 Mon Sep 17 00:00:00 2001 From: Aaron Smith Date: Fri, 22 Jan 2021 20:31:13 -0600 Subject: URL typo --- challenge-096/aaronreidsmith/blog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/challenge-096/aaronreidsmith/blog.txt b/challenge-096/aaronreidsmith/blog.txt index 31d44ad0a0..1f42919f79 100644 --- a/challenge-096/aaronreidsmith/blog.txt +++ b/challenge-096/aaronreidsmith/blog.txt @@ -1 +1 @@ -https://aaronreidsmith.github.io/blog/perl-weekly-chellanege-096/ +https://aaronreidsmith.github.io/blog/perl-weekly-challenge-096/ \ No newline at end of file -- cgit From 039231a412051b974fb688150fa19bca737a4955 Mon Sep 17 00:00:00 2001 From: Aaron Smith Date: Fri, 22 Jan 2021 20:32:24 -0600 Subject: Newline at end of file --- challenge-096/aaronreidsmith/raku/ch-2.raku | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/challenge-096/aaronreidsmith/raku/ch-2.raku b/challenge-096/aaronreidsmith/raku/ch-2.raku index d38a8c5516..954ddfc648 100644 --- a/challenge-096/aaronreidsmith/raku/ch-2.raku +++ b/challenge-096/aaronreidsmith/raku/ch-2.raku @@ -25,4 +25,4 @@ multi sub MAIN(Bool :$test) { } done-testing; -} \ No newline at end of file +} -- cgit