Forgive me if i'm wrong, but this sounds exactly like the sort of problem that one gives to students (using a familiar dataset like University courses). Gnat53's sole other post also sounds remarkably homework-ish. Gnat53 and reply-ers should refer to Homework Alert! and consider their options!
I do commend Gnat53's attempt at the solution and also bobf's helpful resource reply.