I don't know about the solution of this problem, but giving programming challenges to students (in groups of two) is extremely effective. Ideally, forcing the students to use a different language each time. The evaluation is automatic and both the correctness and the speed of the solution over large inputs need to be evaluated. I've seen groups of otherwise passive and uninterested students spent weekends working really hard on a problem to try to beat the challenge.