title: Randomly distribute people into groups based on condition
body: <p>I have a list of people with their departments. I'm trying to distribute them into groups of equal size with the condition that they are not with people from their own departments where possible. I've got a list of 417 people with 19 departments and trying to put them in groups of 10.</p>
  <p>Here is an example to illustrate what I mean:</p>
  <pre>
  Name   Department
   1   |     A 
   2   |     B
   3   |     B 
   4   |     C
   5   |     C
   6   |     C
   7   |     D
   8   |     D
   9   |     D
  10   |     E
  </pre>
  <p>So here for example, if grouping in 3s I'd get something like
  [1, 4, 7], [3, 6, 9], [2, 10], [5, 8]</p>
  <p>Is there any known algorithm that fixes this problem. I currently have a dataframe that has a similar list to the one illustrated above but unsure on how to proceed from there.</p>