Thoughtworks challenge on HackerEarth