0

I am trying to find an effective approach for generating unique pairings. For example I have a set of Users

[ John, Joe, Tim, Fred, Todd, Kevin ]

I am trying to come up with a program such that each time I run it it will give everyone a different pair

For Example

1st run

John Joe
Tim Fred
Todd Kevin

2nd Run

John Tim
Joe Fred
Kevin Todd

and so on

Im trying to make it such that this algorithm does not repeat a pair until all pairs have gone through

This is not for hw!!! this is for my own personal project.

I am trying to use Node.js for this any advice would be great!!!

  • 1
    Can't you just create a random permutation of the list (using Fisher-Yates shuffle, for example) and then split elements into pairs? – gramonov Sep 21 '14 at 04:20
  • 1
    I think you can, Create all permutations, store it in your back-end, randomly select from previously non selected ones based on user token – user3473830 Sep 21 '14 at 04:28
  • 4
    http://en.wikipedia.org/wiki/Round-robin_tournament#Scheduling_algorithm – David Eisenstat Sep 21 '14 at 04:31
  • possible duplicate of [Scheduling algorithm for a round-robin tournament?](http://stackoverflow.com/questions/6648512/scheduling-algorithm-for-a-round-robin-tournament) – David Eisenstat Sep 21 '14 at 14:28

0 Answers0