Google discusses problems and solutions on its own
See this link for the problem with the Candy configuration: http://code.google.com/codejam/contest/dashboard?c=975485#s=a&a=2
In principle, sweets can be divided into two equal values ββ(from Patrick's point of view), if
C[0] xor C[1] xor C[2] xor ... xor C[N] == 0.
One of these sections is the sum of all the candy values, except for one. To maximize the value of one pile, take the candy with the lowest value and place it in a pile.
Why is this so?
The way I thought about this is that, by definition, Patrick's complement is actually equal to the values ββof hsoring. From the definition of the problem we want
C[i] xor C[j] xor ... xor C[k] == C[x] xor C[y] xor ... xor C[z]
for some items on each side.
Adding RHS to LHS and RHS Outputs
C[i] xor C[j] xor ... xor C[k] xor C[x] xor C[y] xor ... xor C[z] == 0
Since the xoring value with itself gives 0, and the order of xor operations is not important, RHS becomes equal to 0.
Any of the elements in the LHS can move on the right side and equality is still true. Selecting the item with the lowest value makes the best separation between piles.
source share