aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-340/barroff/raku/ch-1.p628
1 files changed, 28 insertions, 0 deletions
diff --git a/challenge-340/barroff/raku/ch-1.p6 b/challenge-340/barroff/raku/ch-1.p6
new file mode 100644
index 0000000000..1ee6646cd6
--- /dev/null
+++ b/challenge-340/barroff/raku/ch-1.p6
@@ -0,0 +1,28 @@
+#!/usr/bin/env raku
+
+use v6.d;
+
+sub duplicate-removal(Str $str --> Str) {
+ my Str $s = $str;
+ while $s ~~ m/ (<:Ll>) {} :my $c=$0; $c / {
+ $s ~~ s/ (<:Ll>) {} :my $c=$0; "$c" //;
+ };
+ return $s;
+}
+
+#| Run test cases
+multi sub MAIN('test') {
+ use Test;
+ plan 5;
+
+ is duplicate-removal("abbaca"), "ca", 'works for "abbaca"';
+ is duplicate-removal("azxxzy"), "ay", 'works for "azxxzy"';
+ is duplicate-removal("aaaaaaaa"), "", 'works for "aaaaaaaa"';
+ is duplicate-removal("aabccba"), "a", 'works for "aabccba"';
+ is duplicate-removal("abcddcba"), "", 'works for "abcddcba"';
+}
+
+#| Take user provided string like "abbaca"
+multi sub MAIN(Str $str) {
+ say duplicate-removal($str);
+}