Solved Gray Code problem with coposition method