title: How to avoid that only one unpopular course is left over in an online enrolment?
body: <p><strong>First Problem</strong>: We are trying to code an online enrolment module in PHP. There are 4 courses A, B, C and D. Each taking place on two dates 1pm and 3pm. Each course takes 4 participants. Altogether we have 16 participants. All participants have to chose two different courses, one on 1pm and one on 2pm. How is it possible to avoid that the last enrolers are only left with the most unpopular course? Let my try to draw what the problem might look like:</p>
  
  <p>X = place ist taken, O = place is free</p>
  
  <pre><code>    1pm           2pm
  A - X X X O   A - X X X O
  B - X X X O   B - X X X O
  C - X X X O   C - X X X O
  D - O O O O   D - O O O O
  </code></pre>
  
  <p>How can we calculate, when a popular course is temporally closed for enrolment and when to open it again?</p>
  
  <p><strong>Second Problem</strong>: How to calculate that with courses of a different size like that:</p>
  
  <pre><code>A - O O
  B - O O O O O O
  C - O O O 
  D - O O O O O
  </code></pre>