• + 4 comments

    SPOILER! Hint if you're stuck:

    Giving chocolate to everyone except the chosen person is the same as taking chocolate away from the chosen person. We don't care about how much chocolate they end up with, only that each person's amount is equal.

    For example:

    Give 5:
     1  3  5
     6  8  5  <-
    
    Take 5:
     1  3  5
     1  3  0  <-
    
     The two results are the same relative to themselves, just shifted:
    
       1  3  0
     + 5  5  5
     ---------
       6  8  5
    

    The problem becomes much simpler now.

    Also remember to look for caching opportunities.