Solved problem 87 in Python.