title: Algorithm to select random pairs, schedule matchups
body: <p>I'm working in Ruby, but I think this question is best asked agnostic of language. It may be assumed that we have access to basic list/array functions, as well as a "random" number generator. Here's what I'd like to be able to do:</p>
  
  <p>Given a collection of <code>n</code> teams, with <code>n</code> even,</p>
  
  <ol>
  <li>Randomly pair each team with an opponent, such that every team is part of exactly one pair. Call this <code>ROUND 1</code>.</li>
  <li>Randomly generate <code>n-2</code> subsequent rounds (<code>ROUND 2</code> through <code>ROUND n-1</code>) such that:
  <ul>
  <li>Each round has the same property as the first (every team is a
  member of one pair), and</li>
  <li>After all the rounds, every team has faced every other team exactly once.</li>
  </ul></li>
  </ol>
  
  <p>I imagine that algorithms for doing exactly this must be well known, but as a self-taught coder I'm having trouble figuring out how to find them.</p>