Last active
December 10, 2015 22:08
-
-
Save mariozig/4499858 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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