• + 4 comments

    The above kind of oversimplifies the solution a bit. You can work it out on your own however, so I'll try to sort of describe the process of figuring out the exact mathematical rationale to this.

    ...

    First Step: Take a look at the xor operator, and look at it's properties. Is there some property you can take advantage of to turn this problem into something else? Maybe a counting a problem?

    ...

    Second Step: Since XOR is associative, the sub-arrays don't actually matter in this problem, only the total number of times that each value appears will have any affect on the final solution, regardless of the order it was added into the solution set. Is there some way we can use this property to simplify down our equation?

    ...

    Third Step: We're going to want to find a way to generate the number of times each number is going to be used for each sub array. Brute force this and just sort of print out the results so you can take a look at the information displayed. Is there some pattern we can make use of to help speed up our calculation? Is there some degree of symmetry in the values being used to calculate each numbers appearances, does this symmetry ever change? And if so, how, and is there any way we can make use of this change to potentially solve the problem?