TITLE: Generate all binary numbers, a single bit flip a time
QUESTION [5 upvotes]: Is it possible to sequentially generate all $n$-bit configurations (say, the binary representation of a an $n$-digit number), a single bit flip a time, in such a way that no configuration is generated twice?
If yes, is there an algorithm for this that doesn't need to remember which configurations have already been generated?

Example for 3-bit configurations
OOO  OOX  OXX  OXO  XXO  XOO  XOX  XXX

Subsequent configurations differ only in a single bit.

REPLY [5 votes]: Yes, it's possible.
A loose inductive proof:  You've demonstrated it for three bits.  If you can run through all combinations of three bits, you can run through them again.  (Running through the same sequence of bit flips again will also generate all three-bit combinations.  The terms in the particular sequence of generated three-bit combinations will be the exclusive-OR of the corresponding terms in the sequence you have in your question.)
So, run through all three-bit combinations once, flip the fourth bit, run through all three-bit combinations again.  Now you've just run through all four-bit combinations.  Flip the fifth bit, and run through all four-bit combinations again.  Repeat until you're sick of flipping bits, and you've won.