All Gray Codes
Print all 2N bit strings of length N in reflected Gray code order (consecutive strings differ in exactly one bit), starting from all zeros.
Input: one integer N.
Output: 2N lines of N-bit strings.
Constraints:
- 1 ≤ N ≤ 12
Sample Tests
Input 1
2
Output 1
00 01 11 10
Input 2
1
Output 2
0 1
Discussion (opens after you solve — no spoilers before)
No comments yet.