TITLE: Turning on a nuclear briefcase with the smallest possible number of keystrokes
QUESTION [7 upvotes]: On the front panel of the "nuclear briefcase" there are $12$ buttons. Each button controls its own switch: pressing it toggles it from ON to OFF and back. The initial position of the switches is unknown. The nuclear case triggers an inaudible (ultrasonic) frequency alarm when at least eight switches are in the ON position.
Find the shortest way using as few keystrokes as possible to ensure that the suitcase will sound an alarm.

I tried to do this with examples, but actually I've not idea how can I determine which button to press.

REPLY [3 votes]: (I improved my previous answer, and now I think it corresponds to Delta Account's answer, but maybe in a bit more detail.)
Consider the following list of $16$ switch states where 0 corresponds to "in its original position" and 1 corresponds to the opposite:
000000000 0 0 0
000000000 0 0 1
000000000 0 1 1
000000000 0 1 0
000000000 1 1 0
000000000 1 1 1
000000000 1 0 1
000000000 1 0 0
111111111 1 0 0
111111111 1 0 1
111111111 1 1 1
111111111 1 1 0
111111111 0 1 0
111111111 0 1 1
111111111 0 0 1
111111111 0 0 0

(The spacing is there to help the pattern be clear, but doesn't mean anything.)
The "all switches are ON" position corresponds to some unknown sequence of twelve 0s and 1s. Whatever it is, it is four steps away from one of the states above. To see this, take an arbitrary state $x_1x_2x_3\dots x_{12}$. Then replace the first $9$ switches by whichever of 0 and 1 occurs more often among them, changing at most 4 switches, and you'll get one of the states above.
To go through the states above in order, we need $9 + 14\cdot1 = 23$ steps: there is one step where we press $9$ buttons to get from one state to the next, and fourteen steps where we just need to press $1$ button.