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