aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-227/barroff/raku/ch-1.p620
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-227/barroff/raku/ch-1.p6 b/challenge-227/barroff/raku/ch-1.p6
new file mode 100644
index 0000000000..de158f3f82
--- /dev/null
+++ b/challenge-227/barroff/raku/ch-1.p6
@@ -0,0 +1,20 @@
+#!/usr/bin/env raku
+
+use v6.d;
+
+sub friday_13th(UInt:D $year --> Int:D) {
+ grep({ $_.day-of-week == 5 }, map({ Date.new($year, $_, 13)}, 1..12)).elems;
+}
+
+#| Run test cases
+multi sub MAIN('test') {
+ use Test;
+ plan 1;
+
+ is friday_13th(2023), 2, 'works for 2023';
+}
+
+#| Take user provided year like 2023
+multi sub MAIN(UInt $number) {
+ say friday_13th($number);
+}