Done HW2. Naive solution without any optimization.