aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarrOff <58253563+BarrOff@users.noreply.github.com>2024-08-18 23:45:52 +0200
committerBarrOff <58253563+BarrOff@users.noreply.github.com>2024-08-18 23:45:52 +0200
commitc0b273edea36c7a7255f0ce11a0f3ca70039158f (patch)
tree309636057025a5c77862eaa52086e58b51f14b03
parent7855c95980ee1f3fe35942fc35c496e686ab33c3 (diff)
downloadperlweeklychallenge-club-c0b273edea36c7a7255f0ce11a0f3ca70039158f.tar.gz
perlweeklychallenge-club-c0b273edea36c7a7255f0ce11a0f3ca70039158f.tar.bz2
perlweeklychallenge-club-c0b273edea36c7a7255f0ce11a0f3ca70039158f.zip
feat: Raku solution for task 1 of challenge 282 from BarrOff
-rw-r--r--challenge-282/barroff/raku/ch-1.p631
1 files changed, 31 insertions, 0 deletions
diff --git a/challenge-282/barroff/raku/ch-1.p6 b/challenge-282/barroff/raku/ch-1.p6
new file mode 100644
index 0000000000..e36bedf883
--- /dev/null
+++ b/challenge-282/barroff/raku/ch-1.p6
@@ -0,0 +1,31 @@
+#!/usr/bin/env raku
+
+use v6.d;
+
+sub good-integer(Int $int where $int > 99) {
+ $int ~~ /
+ [
+ (\d)? {} :my $c=$0; <!before $c>
+ (\d) $1 $1 {}
+ :my $d=$1; <!before $d>]
+ |
+ [
+ ^(\d) $0 {} :my $e=$0; ($e) <!before $e>
+ ]
+ / ?? $1 x 3 !! -1;
+}
+
+#| Run test cases
+multi sub MAIN('test') {
+ use Test;
+ plan 3;
+
+ is good-integer(12344456), "444", 'works for "12344456"';
+ is good-integer(1233334), -1, 'works for "1233334"';
+ is good-integer(10020003), "000", 'works for "10020003"';
+}
+
+#| Take user provided number like 10020003
+multi sub MAIN(Int $int where $int > 99) {
+ say good-integer($int);
+}