solution to grayCode