diff options
| author | BarrOff <58253563+BarrOff@users.noreply.github.com> | 2025-06-22 22:34:40 +0200 |
|---|---|---|
| committer | BarrOff <58253563+BarrOff@users.noreply.github.com> | 2025-06-22 22:34:40 +0200 |
| commit | e2f2ffd5a1b92b482edf0ae7e975d434685b12e8 (patch) | |
| tree | e397b059eb8abefd1c6970418e9113d23966ccf0 | |
| parent | b86529f335115adadcef9e79f791268d998e650a (diff) | |
| download | perlweeklychallenge-club-e2f2ffd5a1b92b482edf0ae7e975d434685b12e8.tar.gz perlweeklychallenge-club-e2f2ffd5a1b92b482edf0ae7e975d434685b12e8.tar.bz2 perlweeklychallenge-club-e2f2ffd5a1b92b482edf0ae7e975d434685b12e8.zip | |
feat: add solution for challenge 326 from BarrOff
| -rw-r--r-- | challenge-326/barroff/raku/ch-1.p6 | 24 |
1 files changed, 24 insertions, 0 deletions
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); +} |
