Solutions to HackerRank.com programming puzzle