diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2025-11-06 00:22:19 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-06 00:22:19 +0000 |
| commit | b56a547511eb8e5be2c141b3c5715aa20a4f0c38 (patch) | |
| tree | 001859b37100dce37793bec1a59533c33537e5ae | |
| parent | 5b404ad73c45c3cb3c5fd40f6c0d79841758f6a7 (diff) | |
| parent | 95d316f3e15e1e3e14db8ceb31115ae8df2a4067 (diff) | |
| download | perlweeklychallenge-club-b56a547511eb8e5be2c141b3c5715aa20a4f0c38.tar.gz perlweeklychallenge-club-b56a547511eb8e5be2c141b3c5715aa20a4f0c38.tar.bz2 perlweeklychallenge-club-b56a547511eb8e5be2c141b3c5715aa20a4f0c38.zip | |
Merge pull request #12977 from ash/ash-346
Task 1 Week 346 in Raku by @ash
| -rw-r--r-- | challenge-346/ash/raku/ch-1.raku | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-346/ash/raku/ch-1.raku b/challenge-346/ash/raku/ch-1.raku new file mode 100644 index 0000000000..3b1cff46f7 --- /dev/null +++ b/challenge-346/ash/raku/ch-1.raku @@ -0,0 +1,25 @@ +# Task 1 of The Weekly Challenge 346 +# https://theweeklychallenge.org/blog/perl-weekly-challenge-346/#TASK1 + +say paren-len '(()())'; # 6 +say paren-len ')()())'; # 4 +say paren-len '((()))()(((()'; # 8 +say paren-len '))))((()('; # 2 +say paren-len '()(()'; # 2 + +# An extra example to find the longest string out of the two options +say paren-len '()((())'; # 4 + +grammar parens { + rule sequence { + <balanced>+ + } + + rule balanced { + '(' <balanced>* ')' + } +} + +sub paren-len($s) { + $s.match(/<parens::sequence>/, :g)>>.chars.max; +} |
