Answer for Bonus question for HackFest (Shaastra 2014)