# Lots of children with Halloween candies

You are a teacher in a big kindergarden and halloween was just yesterday. You decided to put the children into a candy race by dividing them into 19 groups to gather candies from houses nearby (they don't necessarily have the same amount of members in each group):

• First group gathered average only $$3$$ pieces of candy per child,
• Second group gathered average $$13$$ pieces of candy per child,
• Every subsequent group gathers $$10$$ candies more than the previous group.

In math language;

To make it more clear, $$A_{n}=10n-7$$ where n is the group number and $$A_{n}$$ is the average number of candies gathered per child in the $$n$$th group.

You think to give a moral to the all groups at once, you take $$18$$ members from 19th group and put them one by one into each group (1st, 2nd, 3rd... 18th) and you noticed that every group's average gathered candies become $$3$$ more (including 19th group!), such that;

• First group gathered an average of only $$6$$ candies per child,
• Second group gathered an average of $$16$$ candies per child, etc...
• Even the last group's (19th) gathered average became $$3$$ more!

So

How many children are there in the kindergarden?

• Is it the case that each group $j$ has $10j-7$ candies per child at the beginning and then $10j-4$ candies per child at the end? Sorry, the wording is a bit confusing. – hexomino Nov 1 '18 at 12:19
• @hexomino yes exactly. $j$ is from $1$ to $20$. – Oray Nov 1 '18 at 12:24

I think the number of pupils is (edited with $$19$$ groups)

$$570$$

Reasoning

Let $$n_j$$ be the number of pupils in group $$j$$ and $$c_j$$ be the total number of candies collected by group $$j$$ ( $$j = 1,\ldots,19$$). Then, we have $$\frac{c_1}{n_1} = 3 \,\,, \,\, \frac{c_2}{n_2} = 13\,\,,\ldots\, \frac{c_{19}}{n_{19}} = 183$$ Now suppose that the pupil who moved from group $$19$$ to group $$i$$, for $$i = 1,\ldots,18$$, brought $$d_i$$ candies with them. This action increases the candy average in each group by $$3$$, hence we have $$\frac{c_1 + d_1}{n_1 + 1} = 6 \,\,,\,\, \frac{c_2 + d_2}{n_2 +1} = 16 \,\,,\ldots, \frac{c_{18}+d_{18}}{n_{18}+1} = 176$$ plus the additional equation $$\frac{c_{19} - \displaystyle \sum_{i=1}^{18} d_i}{n_{19} - 18} = 186$$ If we use the first set of equations to replace the values of $$c_j$$ and multiply out the denominators in the second set of equations we get the following $$(10i-7)n_i + d_i = (10i-4)(n_i+1) \,\,\,,\,\,\, i = 1,\ldots,18$$ $$183 n_{19} - \displaystyle \sum_{i=1}^{18} d_i = 186n_{19} - 3348$$ These equations can be simplified to give $$d_i - (10i-4) = 3n_i \,\,,\,\,i=1,\ldots,18$$ $$3348 - \displaystyle \sum_{i=1}^{18} d_i = 3n_{19}$$ If we sum up all of these equations we get $$3348 - \displaystyle \sum_{i=1}^{18} (10i-4) = 3 \displaystyle \sum_{j=1}^{19} n_j$$ $$\Rightarrow 1710 = 3 \displaystyle \sum_{j=1}^{19} n_j \Rightarrow \displaystyle \sum_{j=1}^{19} n_j = \frac{1710}{3} = 570$$

• @Oray okay I've changed it now. – hexomino Nov 1 '18 at 13:10

I believe there are

39 children in the kindergarten.

At the start,

there was 1 child in each group from 1 to 19, and 20 children in group 20.

The average number of candies (rot13) naq gbgny ahzore bs pnaqvrf for groups 1-19 were, before you redistributed group 20:

$$10x-7$$, where x is the group number.

Now, we can figure out the number of candies each child in group 20 had.

To increase the average of groups 1-19 by 3, each child in group 20 (except the last) had to have $$10x-1$$ candies, where $$x$$ is the group they were assigned. The total number of candies of the first 19 kids in group 20 is $$9+19+29+39...+189$$, or $$1881$$. Now, we can come up with an equation to solve for the number of candies the 20th kid had!

$$x-3 = (1881+x)/20$$

$$20x-60 = 1881+x$$

$$19x-60 = 1881$$

$$19x = 1941$$

$$x = 102.16$$

Well hey, I guess he ate $$.84$$ of his 103rd candy! (Seems like something a kindergartener would do.)

Alright, you want every child to have a whole number of candies? The child in the 19th group actually had $$199$$ candies, not $$183$$. This makes the total $$1897$$ instead of $$1881$$, giving the equation

$$x-3 = (1897+x)/20$$

$$20x-60 = 1897+x$$

$$19x-60 = 1897$$

$$19x = 1957$$

$$x=103$$

• The child in the 19th group can't have 199 candies as the average must be 183. – hexomino Nov 1 '18 at 12:12
• @hexomino isn't it that the average must be at least 10 greater? Or did I misinterpret the question (in which case, my solution is invalid anyway because Group 20 gathered at least 2000 candies, lol) – Excited Raichu Nov 1 '18 at 12:14
• My interpretation was that the first group has 3 per child, the second has 13 per child, the third has 23 per child and so on (up to 20), although I can see now that it is confusing how it it written. – hexomino Nov 1 '18 at 12:17

Let us denote group sizes as A1, A2, ..., A19, A20. Then count the amount of candy both ways and equalize it, since no candy has been lost in the process:

3A1+13A2+...+183A19+193A20 = 6(A1+1)+16(A2+1)+...+186(A19+1)+196(A20-19)

The +1 and -19 represent the changes in kids' amount in the groups.

Now we substract the left part:

0 = (3A1+6)+(3A2+16)+(3A3+26)+...+(3A19+186)+(3A20-19*196);

expand:

3(A1+A2+A3+...+A19+A20) = 19*196-(6+16+26+...+186)

When we sum up the progression on the right, we get:

3(A1+A2+A3+...+A19+A20) = 19*196-19*(186+6)/2 = 19*(196-96) = 1900

Finally we get

(A1+A2+...+A19+A20) = 1900/3 = 633 kids and one third of a body (hope it can still gather candy, though)

You can probably present an example, you don't even have to mutilate anyone - just consider someone small a 1/3 person when counting the average. Happy halloween as well.

• "one third of a body hope it can still gather candy, though" :)) – Oray Nov 1 '18 at 12:52