Department scheduler [simple]
Description:
You are the Head of the Department and your responsibilities include creating monthly schedules for your employees.
Your employees work in shifts. Each shift is 24 hours. Employment policy prohibits employee from working more than 24 hours in a row, so one employee cannot have two consecutive shifts.
There must be n
people at work each day. Arrange employees over the schedule so that their workload is equal or differs from others minimally (i. e. difference between any two employees must not exceed one shift).
If it is not possible to ensure one employee does not work two days in a row due to insufficient staff, return None/null/nil
.
Arguments
- Array of employee names as strings. Example:
["Smith", "Jones", "Gonzalez", "White", "Jackon", "Taylor"]
. - Month and year in
"MMYYYY"
format. n
, the number of employees per shift.
Output
- Array of arrays, each representing a day in the given month. Each day array should contain exactly
n
employee names, representing the employees scheduled for that day. - Or
None/null/nil
, if it is impossible to create a valid schedule.
#Example
Employees Array: ["Smith", "Jones", "Gonzalez", "White", "Jackon", "Taylor"]
Month and year: "022015"
Number of employees per shift: 3
may return
[["Smith", "Jones", "Gonzalez"],
["White", "Jackson", "Taylor"],
["Jones", "Smith", "Gonzalez"],
["Taylor", "White", "Jackson"],
["Smith", "Jones", "Gonzalez"],
["White", "Jackson", "Taylor"],
["Jones", "Smith", "Gonzalez"],
["Taylor", "White", "Jackson"],
["Smith", "Jones", "Gonzalez"],
["White", "Jackson", "Taylor"],
["Jones", "Smith", "Gonzalez"],
["Taylor", "White", "Jackson"],
["Smith", "Jones", "Gonzalez"],
["White", "Jackson", "Taylor"],
["Jones", "Smith", "Gonzalez"],
["Taylor", "White", "Jackson"],
["Smith", "Jones", "Gonzalez"],
["White", "Jackson", "Taylor"],
["Jones", "Smith", "Gonzalez"],
["Taylor", "White", "Jackson"],
["Smith", "Jones", "Gonzalez"],
["White", "Jackson", "Taylor"],
["Jones", "Smith", "Gonzalez"],
["Taylor", "White", "Jackson"],
["Smith", "Jones", "Gonzalez"],
["White", "Jackson", "Taylor"],
["Jones", "Smith", "Gonzalez"],
["Taylor", "White", "Jackson"]]
Here each employee has 14 shifts and no one has two consecutive shifts.
Note: rules for leap years do apply, so keep that in mind ;)
Similar Kata:
Stats:
Created | May 17, 2015 |
Published | May 17, 2015 |
Warriors Trained | 491 |
Total Skips | 152 |
Total Code Submissions | 1251 |
Total Times Completed | 150 |
Python Completions | 87 |
JavaScript Completions | 48 |
CoffeeScript Completions | 8 |
Ruby Completions | 31 |
Total Stars | 28 |
% of votes with a positive feedback rating | 96% of 56 |
Total "Very Satisfied" Votes | 53 |
Total "Somewhat Satisfied" Votes | 2 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 16 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 7 kyu |