solved problem 25 in ipython