24. When taking exams with an electrical examiner, 5 questions appear on the screen. For each question, Petya must answer "yes" or "no" by pressing buttons. Observing the examiner's operation, he determined that there are always more questions that require an affirmative answer and that there are never three consecutive questions that require the same answer. The second question did not trouble Petya. Moreover, he guessed that the answers to the first and last questions should be opposite. Petya gave correct answers to all five questions. What was his answer to the second question? How did Petya manage to answer all the questions correctly?

54
24. According to the condition of the problem, the possible sequences of answers are: 1) no, yes, yes, no, yes; 2) no, yes, no, yes, yes; 3) yes, yes, no, yes, no; 120
4) yes, no, yes, yes, no. Of these, only one contains a different answer to the second question (the 4th). This is what Pete used. (He needed to answer "no" to the second question).