solve gray code