Probably not the best way but it's doable. In fact one of the exercises of the class I took was similar to that (matching Professors to Classes with their constraints and class constraints)