How to solve this problem and others like it?