Skip to content

Instantly share code, notes, and snippets.

@mariozig
Last active December 10, 2015 22:08
Show Gist options
  • Save mariozig/4499858 to your computer and use it in GitHub Desktop.
Save mariozig/4499858 to your computer and use it in GitHub Desktop.
def swingers(couples)
randomized_couples = couples.shuffle
randomized_couples.each_with_index do |couple, index|
if index != randomized_couples.length - 1
randomized_couples[index][1], randomized_couples[index+1][1] = randomized_couples[index+1][1], randomized_couples[index][1]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment