From e2f2ffd5a1b92b482edf0ae7e975d434685b12e8 Mon Sep 17 00:00:00 2001 From: BarrOff <58253563+BarrOff@users.noreply.github.com> Date: Sun, 22 Jun 2025 22:34:40 +0200 Subject: feat: add solution for challenge 326 from BarrOff --- challenge-326/barroff/raku/ch-1.p6 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 challenge-326/barroff/raku/ch-1.p6 diff --git a/challenge-326/barroff/raku/ch-1.p6 b/challenge-326/barroff/raku/ch-1.p6 new file mode 100644 index 0000000000..781f05f607 --- /dev/null +++ b/challenge-326/barroff/raku/ch-1.p6 @@ -0,0 +1,24 @@ +#!/usr/bin/env raku + +use v6.d; + +sub day-of-the-year(Str $date --> Int) { + my $end-date = Date.new($date); + my $start-date = Date.new($end-date.year, 1, 1); + $end-date - $start-date + 1; +} + +#| Run test cases +multi sub MAIN('test') { + use Test; + plan 3; + + is day-of-the-year('2025-02-02'), 33, 'works for "2025-02-02"'; + is day-of-the-year('2025-04-10'), 100, 'works for "2025-04-10"'; + is day-of-the-year('2025-09-07'), 250, 'works for "2025-09-07"'; +} + +#| Take user provided string like 2025-02-02 +multi sub MAIN(Str $date) { + say day-of-the-year($date); +} -- cgit