This is a scheduling problem.
I already did the pattern generation. i have 2 space.......... DNR and EDLNR. D=day, N=night, R=rest
E=early, D=day, L=late .....all this 3 is the 'd' above.
You will need to
1) do the scheduling for the week 1. get me the total scheduling that can be generated for a week(DNR space)
2)From this week 1, need to generate the week 2-5 schedule. Get the total number of schedule that can be generated. (DNR space)
3)convert this 5 week schedule to EDLNR space
i will pass you the c++ program on the pattern generation. from here you can generate the schedule.