Skip to content

Instantly share code, notes, and snippets.

@lexun
Created February 5, 2014 04:00
Show Gist options
  • Save lexun/8817234 to your computer and use it in GitHub Desktop.
Save lexun/8817234 to your computer and use it in GitHub Desktop.
def pairs(participants)
pairs = participants.shuffle.each_slice(2).to_a
if pairs.last.size == 1
loner = pairs.pop
pairs.last << loner.first
end
pairs
end
p pairs(ARGF.read.split)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment