The Gray Code is a sequence of binary numbers of bitwidth n where successive numbers differ only in one bit (see example output). Reference Example input: 3 Example output: 000 001 011 010 110 111 101 100 Notes: This question seems to have a dupe but it's not, for that question is not a code-golf, and it demands different output. It will help to check out it's answers, though. You may assume a variable n which contains the input.