@laurieontech
did something really cool in JS with a bitwise XOR (her answer is above), so I figured I'd update this C++ answer with a bitwise XOR since I love it!

Haha, bitwise xor. Since it's immutable and commutative it'll reduce down to the stray!

I should add that this only works because it’s an odd number of elements in the array. An even number of matching elements cancel each other out to result in the “stray”.

Tuesday (7 KYU): Find the stray number

codewars.com/kata/57f609022f4d534f...

Thanks for this! I don't really know C++, but I figured I'd give it a shot:

@laurieontech did something really cool in JS with a bitwise XOR (her answer is above), so I figured I'd update this C++ answer with a bitwise XOR since I love it!

Looks a bit messy, but I was going for something that might not be too inefficient with a large input array

in c# using linq:

or:

here my cheap solution:

or shorter and more unreadable:

This is the first I'm finding this, excited to play along! Here is yesterday's (edited to make the colors show up):

I don't think this is better than the bitwise solution but it's a different one lol

XOR is a great idea, thanks!

Math for the win! :D

Well I can't think of a better answer for this particular problem domain.

What is this necromancy?

Haha, bitwise xor. Since it's immutable and commutative it'll reduce down to the stray!

I should add that this only works because it’s an odd number of elements in the array. An even number of matching elements cancel each other out to result in the “stray”.

Oh my, it even works in python!

This is one of those moments when I wish gifs worked better on Dev. But yay!

They should work in normal image markdown!

Whaaa?! How did I not know this! ...game changer

Same idea in Haskell: