[Skip To Content]


  1. a = [ 1, 2, 3, 5, 6, 2, 3, 1, 4, 5, 4 ]
  2. puts a.inject( 0 ) { |c, i| c ^= i }

Find the unpaired number in an array. I can’t really think of a situation you’d need to do this, but it’s a really, really elegant solution and that’s why I’m posting it. It’s left to the reader to work out how it works. From.

More about this site...

Last Week’s Top 5 Albums (More »)

  1. The SinglesThe Bluetones
  2. Night on My SideGemma Hayes
  3. PlansDeath Cab for Cutie
  4. Slipway FiresRazorlight
  5. Brain Thrust MasteryWe Are Scientists