The Challenge
The shortest program by character count that outputs the n-bit Gray Code. n
will be an arbitrary number smaller than 1000
100000
(due to user suggestions) that is taken from standard input. The gray code will be printed in standard output, like in the example.
Note: I don't expect the program to print the gray code in a reasonable time (n=100000
is overkill); I do expect it to start printing though.
Example
Input:
4
Expected Output:
0000
0001
0011
0010
0110
0111
0101
0100
1100
1101
1111
1110
1010
1011
1001
1000
n=999
(and since part of the spec is currently that n can be up to 1000)... – Balbo