First solve the problem. Then, write the code