HackerRank Challenge Solutions in Python 2