I have 264 children that need to be divided in 24 play groups. Each group can contain 10, 11 or 12 children. Further, each child can have a list of preferred playmates it would like to be in a group with. This list can be empty, or contain up to 5 children.

Finally, a child with a preference should not be in a group without any of the preferred playmates: at least one of her friends should be in the group.

I tried some pseudo code:

```
Group[11] groups;
List<Node> nodes;
int x = 264;
int nrGroups = 24;
int maxNodesInGroup = 12;
int minNodesInGroup = 10;    
foreach(Node node in nodes) {
  if(node not in any group)
    add to a group
  else
    continue

  foreach(Node preferedFriend in node.Preferred) {
    if(node not in any group) {
      //add to a same group
      continue
    } else {
      continue
    }
  }     
}

```

Is there a way to create the most ideal play groups for each child?