sub task1 ( Date $start, UInt $offset, @holidays --> Date ) { sub is_business_day ($d) { $d.day-of-week ~~ 1..5 and $d ∉ @holidays } return ($start .. *).grep(&is_business_day)[$offset]; } use Test; plan +my @tests = ( '2018-07-04'.Date, '2018-06-28'.Date, 3, <2018-07-03>».Date , 'Example 1' ), ( '2018-07-03'.Date, '2018-06-28'.Date, 3, [] , 'Example 2' ), # Extra tests from ../e-choroba/perl/ ( '2018-07-04'.Date, '2018-06-28'.Date, 2, <2018-07-02 2018-07-03>».Date , 'Land in the middle of holidays' ), ( '2018-07-02'.Date, '2018-06-28'.Date, 2, <2018-07-01 2018-06-30>».Date , 'Holidays on a weekend' ), ( '2025-01-01'.Date, '2024-01-01'.Date, 262, [] , 'Whole year' ), ( '2018-11-20'.Date, '2018-06-28'.Date, 101, <2018-11-16 2018-11-19>».Date , 'Holidays wrap a weekend' ), ( '2013-01-03'.Date, '2012-05-22'.Date, 161, <2012-05-22>».Date , 'Start on a holiday' ), ( '2006-04-05'.Date, '2003-04-20'.Date, 731, < 2001-10-08 2005-02-20 2000-01-07 2003-09-26 2000-08-14 2008-09-22 2003-05-10 2004-05-12 2004-10-12 2008-06-12 2003-06-15 2003-09-20 2006-08-01 2009-02-18 2006-07-11 2008-04-01 2003-10-03 2008-08-07 2008-11-17 2009-02-03 2004-08-18 2005-04-23 2003-08-15 2007-03-22 2004-11-07 2004-08-13 2008-09-04 2003-06-27 2006-07-12 2003-11-06 2000-01-30 2006-11-26 2004-07-05 2007-03-07 2000-12-11 2001-01-17 2007-01-18 2002-05-01 2000-01-06 2000-03-03 2005-09-05 2001-01-03 2005-06-02 2003-08-15 2002-09-13 2006-07-15 2005-06-22 2001-10-27 2005-07-14 2004-09-19 2008-02-10 2003-05-10 2007-08-11 2000-02-05 2002-01-25 2002-03-28 2003-07-26 2007-08-13 2002-03-21 2003-03-09 2006-03-11 2004-03-05 2004-05-08 2006-09-24 2000-10-03 2001-12-19 2003-02-26 2005-10-06 2001-08-23 2004-09-25 2009-12-20 2004-10-10 2005-08-15 2001-11-25 2002-03-11 2007-10-22 2000-10-30 2009-04-14 2009-10-30 2004-09-01 2004-04-11 2000-04-04 2003-11-14 2004-11-16 2001-06-28 2008-11-18 2009-11-16 2006-01-27 2007-08-06 2009-09-14 2000-10-25 2001-09-14 2000-09-17 2007-01-07 2005-02-05 2000-09-20 2002-02-01 2003-05-08 2002-06-03 2006-12-02 2009-08-15 2008-11-22 2002-12-23 2002-06-08 2003-09-27 2004-10-08 2007-12-16 2005-12-19 2003-05-15 2007-10-30 2006-11-13 2005-12-04 2006-09-06 2005-05-08 2007-10-23 2006-05-31 2005-01-16 2009-02-15 2000-05-08 2002-04-13 2000-07-11 2005-05-25 2004-07-03 2007-12-03 2008-07-19 2009-08-27 2004-08-27 2002-03-14 2007-03-29 2005-02-03 2004-10-30 2000-07-14 2004-01-27 2004-12-18 2004-12-08 2005-11-23 2008-04-18 2000-03-06 2009-05-31 2002-08-13 2000-12-25 2008-09-17 2004-06-10 2003-04-29 2003-04-28 2000-04-30 2005-04-18 2003-08-01 2000-05-22 2009-03-18 2002-08-08 2008-11-15 2006-03-17 2003-07-17 2006-10-02 2007-01-17 2009-09-04 2000-04-22 2007-04-23 2006-01-08 2003-08-01 2003-08-11 2003-02-10 2007-04-08 2003-02-26 2002-05-16 2002-11-04 2004-01-07 2001-09-28 2001-11-29 2002-03-19 2009-10-08 2002-08-25 2004-08-22 2003-06-23 2001-05-23 2000-12-02 2000-04-26 2000-05-25 2006-05-15 2006-08-18 2009-12-26 2008-07-31 2009-10-02 2002-07-19 2006-08-01 2000-06-09 2006-04-10 >».Date, 'Huge set of holidays' ), ; for @tests -> ( $expected, $start, $offset, @holidays, $desc ) { is task1( $start, $offset, @holidays ), $expected, $desc; }