Solution for Code Chef Problem 'PERMUT2' (http://www.codechef.com/problems/PERMUT2)