Problem 89 · Medium

Gray Code

Produce a sequence of all n-bit numbers in which neighbouring entries differ by one bit. The visual mirrors the previous sequence and sets a new leading bit for the reflected half.

Open the interactive visualisation