Implemented solution to problem 25