Recursive Solution:

All data structures are global! (Bad style, more speed) Let me know if you have any questions on it.

Code:

void solveRecurse(int currentJob)
{
char currentJobSched = jobs[currentJob].getSchedule();
int jobSize = jobs.size();
char getComp;
if (currentJobSched != '-' && currentJob >= 0)
{
numOfJobs++;
if (numOfJobs > currentBest)
{
currentBest = numOfJobs;
best = jobs;
}
computers[currentJobSched - 97].addJob(jobs[currentJob].getEnd());
}
if (currentJob + 1 < jobSize)
{
for (int i = 0; i < Job::getMachPerJob(); i++)
{
getComp = jobs[currentJob + 1].getComp(i);
if (computers[getComp - 97].isAvailable(jobs[currentJob + 1].getStart()))
{
jobs[currentJob + 1].setSchedule(getComp);
solveRecurse(currentJob + 1);
}
}
jobs[currentJob + 1].setSchedule('-');
solveRecurse(currentJob + 1);
}
if (currentJobSched != '-' && currentJob >= 0)
{
computers[currentJobSched - 97].removeJob();
numOfJobs--;
}
}

Sample test cases: (short ones)

Each line is a job. Int 1 is start time, int 2 is end time. The chars are the potential computers to be scheduled on.

A '-' means that the job is not scheduled. All answers that schedule the same number of jobs are valid.

Remember that all jobs have the same number of computers on which to be scheduled. In other words, in the input file, there are the same # of letters after each job.

Code:

Test case 1:
1 4 a
3 6 a
6 7 a
8 10 a
Answer:
1 4 a
3 6 -
6 7 a
8 10 a
Test case 2:
0 1 a b
0 2 a b
3 6 b a
3 4 b a
2 3 a b
20 21 a b
19 20 b a
5 6 a b
Answer:
0 1 a
0 2 b
3 6 -
3 4 b
2 3 a
20 21 a
19 20 b
5 6 b
Test case 3:
0 4 a b
0 2 a b
3 6 b a
3 4 b a
2 3 a b
20 21 a b
19 20 b a
5 6 a b
Answer:
0 4 -
0 2 a
3 6 a
3 4 b
2 3 -
20 21 a
19 20 b
5 6 b
Test case 4:
0 1 a b c
2 3 b c d
2 3 a b c
4 6 a d c
4 5 a d c
4 5 a d c
6 7 a d c
Answer:
0 1 a
2 3 d
2 3 b
4 6 a
4 5 c
4 5 d
6 7 d

These test cases are rather short. My greedy (wrong) iterative solution solves these no problem. I would be happy to post longer, more challanging samples, if people desire.

In addition, I have been told that Belady's algorithm may be applied to a portion of this problem, both for the recursive and the iterative solutions. Any ideas?