From c29a28ed8b8ba76560ddcddbdaa84c1fd82e90c7 Mon Sep 17 00:00:00 2001 From: Mark <53903062+andemark@users.noreply.github.com> Date: Mon, 4 Mar 2024 15:49:44 +0000 Subject: ch-1.raku --- challenge-259/mark-anderson/raku/ch-1.raku | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 challenge-259/mark-anderson/raku/ch-1.raku diff --git a/challenge-259/mark-anderson/raku/ch-1.raku b/challenge-259/mark-anderson/raku/ch-1.raku new file mode 100644 index 0000000000..26c0180e8e --- /dev/null +++ b/challenge-259/mark-anderson/raku/ch-1.raku @@ -0,0 +1,25 @@ +#!/usr/bin/env raku +use Test; + +is banking-day-offset('2018-06-28', 3), '2018-07-03'; +is banking-day-offset('2018-06-28', 3, ['2018-07-03']), '2018-07-04'; +is banking-day-offset('2018-06-30', 0), '2018-07-02'; +is banking-day-offset('2018-06-30', 8, ['2018-07-04', '2018-07-03']), '2018-07-16'; +is banking-day-offset('2018-07-02', 0), '2018-07-02'; +is banking-day-offset('2018-07-16', 4), '2018-07-20'; + +sub banking-day-offset($date is copy, $offset is copy, @holidays=[]) +{ + $date .= Date; + + loop + { + given $date++ + { + if all(.day-of-week ~~ 1..5, .yyyy-mm-dd !(elem) @holidays) + { + return .yyyy-mm-dd unless $offset-- + } + } + } +} -- cgit