Problem 29. Not optimalized in any way, but python seems to handle it well enough...