Challenge 444: Out of line
An algorithmic puzzle from KCLMS student Anango!
Part (a)
100 children sit in a line, so that everyone has a child to their left and right (except for the two children on the left end and right end of the line).
Each child is given a number of sweets (not necessarily the same for each child).
The teacher selects a child who (a) has at least one sweet, and (b) isn't at the left end of the line. That child gives one of their sweets to the child on their left.
The teacher repeats this process many times. Is it possible for the teacher to repeat the process forever, or will it eventually be impossible?
(The right answer might seem intuitively clear, but you should look to provide a convincing explanation of your answer.)
Part (b)
The process above is amended: the teacher selects a child who (a) has at least two sweets, and (b) isn't at either end of the line. That child gives one sweet to each of their neighbours. (In other words, one sweet goes to the left, and one goes to the right.)
Now can the process be repeated forever?
![King's Maths School [logo]](/image-library/logos/kcl-ms-logo.jpg)