Question: > 
> 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.

Answer: 
(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 `0`s and `1`s. 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.
let's divide 12 buttons into two groups of 9 buttons and 3 buttons.
consider a group of 9 buttons there may be 5 switched on switches and in this case we need to switch three switches so that we have a total of 8 switched on switches. in a group of three buttons, we can consider all possible combinations and in this case we will definitely have 8 switches on. the number of combinations in a group with three buttons will be $2^3-1=7$ , since initially there is already a combination . now if, in our original group with nine buttons, five of these switches were not on but off, then we need 9 more moves to turn all the switches and then we will have 5 switched on switches, then again all the combinations to the second group with three buttons and then we will certainly have 8 switched on switches and the total number of moves is $7+9+7=23$