Solution for the CodeChef practice problem http://www.codechef.com/problems/LUCKYSTR