My solution for www.pythonchallenge.com.