title: Divide students into non-uniform sized groups by preference
body: <p>Every year my mom (who is a teacher) takes her class on an overnight trip and has to assign students to rooms. Right now she just does this by hand via trial and error, I'd like to write an algorithm to do this.</p>
  
  <p>She has the following constraints:</p>
  
  <ul>
  <li>Each student has 3 other students they would like to be with and optionally 1
  student they do not want to be with</li>
  <li>Each student must be with at least 1 of the 3 other students they prefer</li>
  <li>Each student cannot be with the student they dislike</li>
  <li>Not all rooms have the same number of beds</li>
  <li>Assume gender is not a factor (they are split into separate buildings so each one is an independent problem)</li>
  </ul>
  
  <p>Either a specific solution or pointing me to the generalized version of the problem (e.g. knapsack) is fine. I also realize it is possible to have a scenario where there is no solution, if that ever happens it will just be up to her to figure out what she wants to do. I also don't necessarily need to find the <em>optimal</em> solution, just valid arrangements.</p>
  
  <p>I've seen a couple similar problems, but none of them address the one or more preferred and non-uniform number of beds constraints.</p>