Hi all,
I need to write some php code to choose all possible combinations to schedule classes based on a pre-set pattern.
For example, if I want to schedule a 3-hour course in the highlighted times in the timetable attached using one 2-hour block and one 1-hour block there are 40 possible combinations.
Monday from 7:30 to 9:30 is the 2-hour block plus 1-hour from either of the 8 hours from the other 4 days gives 8 possibilities. Do this 5 times and there are 40 combinations.
I've researched a lot and have read that brute-force is the best method. Others say use Recursive functions/Multi Dimensional Array Combinations, yet others say use the permutations formula.
Does anyone have any experience with such code?
Ideally I would like the output to be as follows for 3 hrs = 1x2hr + 1x1hr (as described above) :
1 | Monday | 7:30 | 2 hours
1 | Tuesday | 9:30 | 1 hour
2 | Monday | 7:30 | 2 hours
2 | Tuesday | 10:30 | 1 hour
3 | Monday | 7:30 | 2 hours
3 | Wednesday | 7:30 | 1 hour
4 | Monday | 7:30 | 2 hours
4 | Wednesday | 8:30 | 1 hour
..... and so on ......
Any help/feedback/sample code would be greatly appreciated.