I have 4 binary bits
Bit 3 Bit 2 Bit 1 Bit 0
Normally the answer is simple: 2^4, or 16 different combinations; and it would looks something like the following:
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
However, The LSB (Bit 0) changes state every iteration.
I need an algorithm where the state of a bit only changes once through all the iterations; i.e, I need all my bits to act like the MSB (Bit 3).
How can I do this?
Edit
It seems that most people are converging to there being only 5 possible solutions. However this assumes there is a starting point for the value and an ending point. This doesn’t matter so I’m going to give a real world scenario to better explain.
Suppose I have an digital alarm clock that gives me 4 outputs. Each output can be programmed to go on at a certain time and off at a certain time and are programmed independent of each other, eg. I can program output 1 to go on at 1 am and off at 3 am, while I can program output 2 to go on at 7 pm and off at 2 am. There are no restrictions to how long each output can stay on.
Now I want to hook this alarm clock to a computer and get as close as possible to the current correct time. i.e If the clock says the time is 2:15 pm, my computer knows that the alarm is within the 12 pm to 6 pm range for example. I want to be able to get the smallest possible range. Whats the smallest possible range I can get?
Therefore, you can have at most 4 state changes, and at most 5 different values.
Example:
Edit:
Very well, let’s restate from what you mean rather than from what you say.
Therefore, you can have at most 8 state changes, and at most 8 different values (since the last state change necessarily brings all bits back to their initial state)
Example:
So, by setting the outputs for: 3 AM – 3 PM, 6 AM – 6 PM, 9 AM – 9 PM and noon – midnight, you can determine which 3-hour period it is from the outputs. I’d suggest plugging wires into the visual output instead.