Given:
- An array of work hours
[0,8,8,8,8,8,0]
where the elements represent the number of work hours per day in a normal work week, starting from Sunday (day 0 of the week) - A list of employees like
{1,Mark Virtue}
with anid
andname
, and optionally employee-specific overrides to the normal work week
Implement:
A find_available_work_hours
method with the signature find_available_work_hours(user_id, from, to)
that outputs a list of available work hours for each date in the given date range from..to
(inclusive).
Employee-specific overrides to the normal work week are defined by an array of per-user work week blocks:
[
{ 1, "01/01/2015", "12/31/2015"}, [0,4,4,8,8,4,0]},
{ 1, "01/01/2016", null}, [0,8,8,8,8,0,0]}
]
where each block has a user id, an optional start or end dates, and an array of hours in the same format as the normal work week (work hours per day in a week starting with Sunday).
The output of find_availabile_work_hours(1,"12/06/2015","12/09/2015")
should be sorted by date, and have the following format:
"12/06/2015",0
"12/07/2015",4
"12/08/2015",4
"12/09/2015",8
The program should ignore blank lines and any lines, or lines that start with a #
.
# example input for the find availability problem
# company work hours
0,8,8,8,8,8,0
# employees
1,Mark Virtue
2,Anne Prins
# mark's availability
1,"01/01/2015","12/31/2015",[0,8,8,4,10,10,0]
1,"01/01/2016",null,[0,8,8,8,8,8,0]
# anne's availability
2,"03/16/2016","06/16/2016",[0,8,8,8,8,0,0]
# find availability for user and dates
1,"12/16/2015","01/15/2016"
Design and implement a mechanism to factor in company holidays.