add problem 3 to python and ruby