Let the number of students in class $A$ be $a$, then the number of students with grades 5, 4, 3, 2 are $0.15a$, $0.3a + 4$, $0.25a$, $0.2a$. Their sum is $a$, from which $a=40$, and the distribution according to the above is: 6 excellent, 16 good, 10 average, 8 sufficient. Thus, the average grade is $(6 \cdot 5 + 16 \cdot 4 + 10 \cdot 3 + 8 \cdot 2) : 40 = 3.5$.

In class $B$, there are $6-1=5$ excellent students. The class size is either 42 or 38, accordingly the number of 4s is 17 or 15. Thus, the number of 3s and 2s is $42-17-5=20$ or $38-15-5=18$. Five-sixths of these are 3s, so the class size must be divisible by 6. This is only possible with the latter option, so there are 15 average, 3 sufficient, and 15 good students, the class size is 38, and the average grade is: $(5 \cdot 5 + 15 \cdot 4 + 15 \cdot 3 + 3 \cdot 2) : 38 = 3.58$.

Thus, class $B$ won the competition.

Nagy Géza (Debrecen, Ref. g. I. o. t.)

Remarks: 1. The average of class $A$ can also be obtained without calculating the class size. The 4s indeed make up $100-(15+25+20)=40\%$ of the class, so the average is $(15 \cdot 5 + 40 \cdot 4 + 25 \cdot 3 + 20 \cdot 2) : 100 = 3.5$.

2. Using the results of class $A$, the answer can be given without deciding on the class size $b$ of class $B$. In this case, the number of 5s is 5, the number of 4s is $b/2-4$, so the number of the remaining is $b-5-(b/2-4)=(b-2)/2$, of which the number of 3s is $(5b-10)/12$, and the number of 2s is $(b-2)/12$. The average grade is:

$$
\frac{1}{b}\left[5 \cdot 5 + 4\left(\frac{b}{2}-4\right) + 3 \cdot \frac{5b-10}{12} + 2 \cdot \frac{b-2}{12}\right] = \frac{41}{12} + \frac{37}{6b}
$$

The excess of this compared to the average of class $A$ is

$$
\frac{41}{12} + \frac{37}{6b} - 3.5 = \frac{37}{6b} - \frac{1}{12} = \frac{74-b}{12b}
$$

This could only be negative if $b>74$. However, $b$ is at most 42, so class $B$ won.

Bollobás Béla (Budapest, Apáczai Csere J. gyak. g. II. o.t.)
Two parallel classes of a school are in academic competition. One class has 2 more students than the other. By mid-term, there were no failing students in either class. In class $A$, $15\%$ of the students are excellent and have outstanding results (5s), a quarter of the class has average results (3s), a fifth of the class has satisfactory results (2s), and the number of good students (4s) is 4 more than twice the number of 5s. In class $B$, there is 1 fewer 5 than in class $A$, the number of 4s is 4 less than half the class, and $5/6$ of the remaining students have average results. Which class won the competition with a better average grade?