Successful solution for Chef and Reversing problem - http://www.codechef.com/AUG14/problems/REVERSE