private void rec_GenerateSchedules(List<List<List<Section>>> temp, int courseCount, int loopCount, int k, Schedule currSched) { if (loopCount >= courseCount && currSched.courses.Count() != 0) { Schedule listCpy = new Schedule(); foreach (Section section in currSched.courses) { listCpy.courses.Add(section); listCpy.total_weight += section.weight; } // add an extra weight for the schedule as a whole if (this.schedWideWeighting == 1) listCpy.calcSchedWeight(this.schedWidePref, this.schedWideMult); addtoList(possibleScheds, listCpy); //ctr++; //System.Diagnostics.Debug.WriteLine(ctr); return; } foreach (List<Section> currIteration in temp[k]) { //test each section in the iteration for a conflict with the schedule. bool test = false; foreach (Section currSection in currIteration) { if (IsConflict(currSection, currSched.courses)) { test = true; } } //if no conflict test=false then add the sections to the currSched if (!test) { foreach (Section currSection in currIteration) { currSched.courses.Add(currSection); } rec_GenerateSchedules(temp, courseCount, loopCount + 1, k + 1, currSched); for (int i = 0; i < currIteration.Count(); i++) { currSched.courses.RemoveAt(currSched.courses.Count() - 1); } } } }