solved problem 14 in python