solved problem 17 in python
solved problem 17 in ruby