Algorithmic challenges from hackerrank.com, solved in Python