Solving it in general is quite trivial - solving it 'fast' is another story. I can write a backtracking algorithm or a constant propagation one on spot. Yet, I am not quite sure how efficient the latter would be, the former is obvious a brute force one.