have to place nurses in a shift rota. Each day 10 nurses should work the morning shift (M), 8 nurses should work the postmeridian shift (P) and 2 nurses should work the night shift (N). Extra nurses work a virtual shift (J). They will be used to give an extra day off to the ones who worked too many hours. The day off is called 'rest' (R). M shift is 7h P shift is 7h N shift is 10h J shift is 7h Nurses should work 38h/week in average. Summing all nurses, each day 7*10+7*8+10*2=146h are worked. Each week 7*146=1022h are worked. The needed number of nurses is round(1022/38)=27 I found a solution which is shown in the attachment. Each employee follows a rota made of 6 work days + 2 days off. This means 6*7=42h worked every 8 days (=36.75h / week) when no night shift is worked and 4*7+2*10=48h worked every 8 days (=42h /week) when the night shift is worked. However this shift rota must be changed so that: 1. all nurses work the same quantity of night shifts in the long run 2. 6 P shifts (or M shifts) in a row are too many. Mix M shifts and P shifts so that max 4 equal shifts in a row are worked (e.g. MMMPPPRR or MMMMPPRR or PPPPMMRR or PPPMMMRR). 3. all nurses work the same shifts in the long run 4. the nurses working the MMPPNNRR rota will receive an extra day off every 16th day to compensate for the extra work (you can use nurses working the J shift as substitutes). Ideally we will get a shift matrix M*27, where 27 is the number of rows (equal to the number of nurses) and M is a number of days (probably a multiple of 8) so that after M days the nurse at row 1 will start the rota at row 2, the nurse at row 2 will start the rota at row 3, etc. Finally the nurse at row 27 will start the rota at row 1. Note that the night shift N only can be followed by a 2nd N shift or by 2 R shifts. Please feel free to ask any question. While only elementary math skill is needed, the problem can be tricky and time consuming. Dont jump in. Weight carefully all details.