add problem 4 to python and ruby