Adding solution to HAMM problem.