Solved problem15 in python3