Solved gray code problem.