title: Match people into groups according to food preference
body: <p>I am looking for an algorithm which helps me to distribute people into 3 groups (a, b , c). The people in a group should fit together, which means that the food preferences should match in a way that they all can agree to the same kind of food.  Each cluster (sub-group) within the group consists of 6 people.
  Let's say there are 4 types of food preferences:</p>
  <ol>
  <li>The person likes to eat meat</li>
  <li>The person likes to eat vegetarian food</li>
  <li>The person likes to eat vegan food</li>
  <li>The person has no food preferences, which means the person basically likes to eat everything</li>
  </ol>
  <p>I want to distribute the people into 3 logical groups:</p>
  <ul>
  <li>Group a: meat and no_food_preference</li>
  <li>Group b: vegan, vegetarian and no_food_preference</li>
  <li>Group c: vegetarian  and no_food_preference</li>
  </ul>
  <p>I use the people with no_food_preference to fill up the cluster in order to make sure that each cluster contains 6 people.</p>
  <p>After distributing  all people into groups, each group will consist of multiple of 6 people.</p>
  <p><strong>My problem:</strong> I tried very hard, but I can not find an algorithm which does this for me. I find it very hard to handle the fact, that the algorithm should handle any number of participants.</p>
  <p><strong>Example:</strong></p>
  <pre class="lang-py prettyprint-override"><code>import pandas as pd
  
  df = pd.DataFrame(
   {
   &quot;user_id&quot;: [i for i in range(1, 55)],    
   &quot;Master_FoodPreference&quot;: [&quot;meat&quot;, &quot;vegetarian&quot;, &quot;meat&quot;, &quot;vegan&quot;, &quot;meat&quot;, &quot;vegetarian&quot;, &quot;meat&quot;, &quot;vegetarian&quot;, &quot;no_food_preference&quot;, 
                             &quot;meat&quot;,'no_food_preference', 'vegetarian',&quot;meat&quot;, &quot;meat&quot;,
                             &quot;vegetarian&quot;, &quot;vegetarian&quot;, &quot;vegan&quot;, &quot;vegetarian&quot;, &quot;vegetarian&quot;, &quot;no_food_preference&quot;, &quot;vegan&quot;, 
                             &quot;vegetarian&quot;, &quot;vegetarian&quot;, &quot;vegetarian&quot;, &quot;vegetarian&quot;, &quot;vegetarian&quot;, &quot;vegetarian&quot;,
                             &quot;meat&quot;, &quot;vegetarian&quot;, &quot;meat&quot;, &quot;vegetarian&quot;, &quot;no_food_preference&quot;, &quot;vegetarian&quot;, &quot;vegetarian&quot;, &quot;vegetarian&quot;, 
                             &quot;vegetarian&quot;, &quot;vegetarian&quot;, &quot;vegetarian&quot;, &quot;vegetarian&quot;, &quot;vegetarian&quot;, &quot;no_food_preference&quot;, 
                             &quot;no_food_preference&quot;, &quot;no_food_preference&quot;, &quot;meat&quot;, &quot;no_food_preference&quot;, &quot;meat&quot;, &quot;meat&quot;, 
                             &quot;vegan&quot;, &quot;no_food_preference&quot;, &quot;no_food_preference&quot;, &quot;vegan&quot; ,&quot;no_food_preference&quot; ,&quot;vegan&quot; ,&quot;vegan&quot; ]
   }
  )
  
  df.head() 
  &gt;&gt;&gt;&gt;
    user_id   Master_FoodPreference
  0   1       meat
  1   2       vegetarian
  2   3       meat
  3   4       vegan
  4   5       meat
  </code></pre>
  <p>How would you group these people into <code>group_a</code>, <code>group_b</code> and <code>group_c</code>?</p>
  <p><strong>EDIT - Group Composition</strong>:
  Each group (a,b,c) will get a specific label:</p>
  <ul>
  <li>Group a: People will cook a meal with meat</li>
  <li>Group b: People will cook a meal which is vegan</li>
  <li>Group c: People will cook a meal which is vegetarian</li>
  </ul>
  <p>This means, we should try to bring most vegeterians into <code>group_c</code>. If <code>group_c</code> is complete, we put them into <code>group_b</code>. Note: we can not put vegans into <code>group_c</code>, because vegans don't eat vegy-food.</p>