NewProject Coding is here — build features and fix bugs in real codebases with an AI assistantSee what's new

Given an array of users, implement a function that generates random pairings such that each possible pairing configuration is equally likely. The pairing should follow these rules:

  • Each pair is formed by randomly selecting two distinct users until fewer than two users remain.
  • The pairing process must be uniformly random, ensuring that every valid set of pairings has an equal probability of being chosen.
  • If the total number of users is odd, one user will remain unmatched.
Stdout
-