add problem 18 to php, python, and ruby