What we have to do is to find the largest common divisor of the two numbers: 12 and 30. It must be at least 2, since they're both even, and at least 3 since both are divisible by 3, so that means that it it also must be at least 6 (2*3=6; if they're divisible by 2 and 3, they must be both divisible by 6).
But they have no bigger divisor than this.
So that means that the number of groups will be 6 (both groups can be divided into 6). It will have 2 (12/6=2) newcomers and 5 (30/6=5) advanced swimmers.