title: What's the grouping plan so that every two people are grouped together just once?
body: <p>So, we have N people. </p>
  
  <p>Everyday, we make N/2 groups out of them, i.e., 2 people are in one group.</p>
  
  <p>We keep grouping everyday, until every two people have been paired exactly once, no more no less.</p>
  
  <p>Please give the grouping plan for every day.</p>
  
  <hr>
  
  <p>Here are my thoughts:</p>
  
  <p>Out of N people, there are <code>N * (N-1) / 2</code> possible pairs. Since everyday we will have <code>N/2</code> pairs, totally we will need <code>N-1</code> days.</p>
  
  <p>So basically, if our algorithm takes a list of N people as input, we will output <code>N-1</code> lists, each list will contain the pairs for a day.</p>
  
  <hr>
  
  <p>But how to organise these <code>N * (N-1) / 2</code> pairs into <code>N-1</code> days?</p>
  
  <p>I know how to do it in a bruteforce way, like worst case, we try every combinations of pairs for every day, or better use hashtset to see whether a combination for a day is possible or not (a hashset for a day). </p>
  
  <p>But I think there must be a more elegant and efficient way to solve the problem. Graph?</p>