A note on a candy sharing game
Suppose k students sit in a circle and are each distributed some initial amount of candy. Each student begins with an even amount of candy, but their individual amounts may vary. Upon the teacher’s signal, each student passes half of their candy to their left and keeps half. After this step, any student with an odd amount of candy receives an extra piece. The game ends if all the students are holding the same amount of candy. We prove, in a generalized setting, that for any initial distribution of n pieces of candy, the game terminates after O(log n) many iterations and each student ends with n/k + O(log n) many pieces. Moreover, there exist initial distributions for which the O(log n) term cannot be improved.