I’m quite thick when it comes to math cleverness and I need some help, I need to implement a rota system where we’d get groups of people “on call” for a week, said groups will recur throughout the year.
This will be CGI scripts in Perl with a db in the backend.
Easier with an example, say 3 groups the 1st is on call from this Wednesday to next Wednesday when at midnight group 2 will be on call for the week on wednesday, after them the last group will be on call the same way. After the last group the first guys are on call again Wed – Wed and the whole thing keeps repeating.
It also has to accomodate temp changes to individuals in each group which will hold only for the current session and not for the whole series.
Imagine google calendar, basically that but developed buy one guy, me, and within a week, gotta love management.
Question:
What I’m thinking but don’t know how to do is identify, having the group’s static week number (group 1 week 1; group 2 week 2 .. etc), which group is “on call” right now.
Simply divide the week number by the group number. But keep in mind that the first group will be equal to 1, the last group to 0.
E.g. if you imagine the start of the year for 5 groups;
for week 1 % 5 = 1; -> group one
for week 2 % 5 = 2; -> group two
for week 3 % 5 = 3; -> group three
for week 4 % 5 = 4; -> group four
for week 5 % 5 = 0; -> group group five
And it repeats…
for week 6 % 5 = 1; -> group one
…