From 802089d873dc4dcdaffc67f6eb5a09d383169a87 Mon Sep 17 00:00:00 2001 From: BarrOff <58253563+BarrOff@users.noreply.github.com> Date: Mon, 29 Sep 2025 01:09:38 +0200 Subject: feat: add solution for challenge 340 from BarrOff --- challenge-340/barroff/raku/ch-1.p6 | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 challenge-340/barroff/raku/ch-1.p6 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); +} -- cgit