I didn't know this either, not having worked with XOR much before. But
while doing the problem, I knew there had to be a simple solution
because going through a huge list of combinations would be ridiculous.
On a hunch, I did the total XOR for the samples, and saw that the one
where it equaled 0 was successful.

I thought about it for about 15 minutes before realizing that (a xor
a) == 0. Once I realized that, the rest fell into place.

On May 10, 7:26 am, Marcelo Ramires <[email protected]>
wrote:
> Right, I didn't ask how does one figure out that it's about XOR, because
> this I've figured out too when I was solving, what I didn't know and
> surprised me that everybody else knew is:
>
> *If the xor of all numbers is zero, you can pick any candy, and the xor to
> this number is going to be equal to the xor from the rest of them.*
>
> I did't know this property of XOR, must be because I've never worked with
> XOR in integers, but I'd say that if I had only used it a little I wouldn't
> catch it quickly...
>
>
>
>
>
>
>
> On Mon, May 9, 2011 at 6:01 PM, Reniery O'Hara <[email protected]> wrote:
> > Hi,
> > One could come to this solution by understanding the Sean adding skills,
>
> >   1100
> > + 0101
> > ------
> >   1001
>
> > compare this with the XOR truth table and you will have a match.
> > As others posted before practice will help us to see these patterns while
> > reading the problems.
>
> > (Personally I didn't use an explicit integer XOR, I used mod 2)
>
> > On Mon, May 9, 2011 at 4:59 PM, rahul raghavendra 
> > <[email protected]>wrote:
>
> >> u can do a lot of stuff with the bitwise operators , u just gotta
> >> experiment with it
>
> >> On Tue, May 10, 2011 at 2:21 AM, Morgan Bauer 
> >> <[email protected]>wrote:
>
> >>> XOR is the bread and butter of Symmetric Cryptography.
> >>> ~mhb
>
> >>> On Mon, May 9, 2011 at 4:44 PM, Marcelo Ramires
> >>> <[email protected]> wrote:
> >>> > I understood how to solve this, but how does one come to this solution
> >>> ?
>
> >>> > If the xor of all numbers is zero, you can pick any candy, and the xor
> >>> to
> >>> > this number is going to be equal to the xor from the rest of them.
>
> >>> > I get this, if I have 9 numbers with XOR 3, XORing it with 3 will get
> >>> me
> >>> > zero.
>
> >>> > How has everybody thought of this at the same time ? have I skipped a
> >>> logics
> >>> > class ? is this concept so disseminated among coders ?
>
> >>> > I had never XORed nubmers before this code jam, only booleans, and I
> >>> didn't
> >>> > know you could.
>
> >>> > As a side questions, can anybody tell me any alternative uses for
> >>> XORing
> >>> > integers other than 1 and 0 ?
>
> >>> > Thanks!
>
> >>> > Marcelo Ramires
>
> >>> > On Sun, May 8, 2011 at 1:50 AM, vivek dhiman <[email protected]>
> >>> wrote:
>
> >>> >> Lucky!
>
> >>> >> You are right.
>
> >>> >> if xor of two lists is same. (say xor1 = xo2)
>
> >>> >> So the exor of these two wil be 0  (xor (xor1,xor2) = 0)
> >>> >> Or in other words lists can be divided if the xor of all the elements
> >>> is
> >>> >> zero.
>
> >>> >> :)
>
> >>> >> On Sun, May 8, 2011 at 8:17 AM, keshav agarwal <[email protected]>
> >>> >> wrote:
>
> >>> >>> please tell me of my logic was correct or i just got lucky to get it
> >>> >>> correct
>
> >>> >>> if xor to a list of nos. is zero only then the division is possible
> >>> >>> in this case patrick can be given the one candy with lowest value
> >>> while
> >>> >>> sean keeps the rest
>
> >>> >>> if      xor(n nos.)=0
> >>> >>> then       (nth no.) xor (xor of n-1 nos.)=0
>
> >>> >>> so patrick gets the nth candy and sean keeps the rest
>
> >>> >>> --
> >>> >>> You received this message because you are subscribed to the Google
> >>> Groups
> >>> >>> "google-codejam" group.
> >>> >>> To post to this group, send email to [email protected].
> >>> >>> To unsubscribe from this group, send email to
> >>> >>> [email protected].
> >>> >>> For more options, visit this group at
> >>> >>>http://groups.google.com/group/google-code?hl=en.
>
> >>> >> --
> >>> >> Regards
> >>> >> Vivek Dhiman
>
> >>> >> --
> >>> >> You received this message because you are subscribed to the Google
> >>> Groups
> >>> >> "google-codejam" group.
> >>> >> To post to this group, send email to [email protected].
> >>> >> To unsubscribe from this group, send email to
> >>> >> [email protected].
> >>> >> For more options, visit this group at
> >>> >>http://groups.google.com/group/google-code?hl=en.
>
> >>> > --
> >>> > You received this message because you are subscribed to the Google
> >>> Groups
> >>> > "google-codejam" group.
> >>> > To post to this group, send email to [email protected].
> >>> > To unsubscribe from this group, send email to
> >>> > [email protected].
> >>> > For more options, visit this group at
> >>> >http://groups.google.com/group/google-code?hl=en.
>
> >>> --
> >>> You received this message because you are subscribed to the Google Groups
> >>> "google-codejam" group.
> >>> To post to this group, send email to [email protected].
> >>> To unsubscribe from this group, send email to
> >>> [email protected].
> >>> For more options, visit this group at
> >>>http://groups.google.com/group/google-code?hl=en.
>
> >> --
> >> *
> >> K.Rahul  )
>
> >> *
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "google-codejam" group.
> >> To post to this group, send email to [email protected].
> >> To unsubscribe from this group, send email to
> >> [email protected].
> >> For more options, visit this group at
> >>http://groups.google.com/group/google-code?hl=en.
>
> > --
> > Reniery
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "google-codejam" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> >http://groups.google.com/group/google-code?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"google-codejam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en.

Reply via email to