How to Split a Class Into Random Groups — and Keep Two Students Apart

It is Friday afternoon and you are splitting a class of 28 into groups of four. You draw names from a hat, read them out, and there it is again: Chloe Bennett and Dylan Marsh, in the same group, for the third time this term. Everybody in the room knows what happens next — you swap one of them out by hand, trade a couple of names between groups until the two of them are apart, and the groups are no longer the ones the hat drew. The draw was random. The groups are not.

That is the whole problem with splitting a class by hand. The random part is easy. The part that breaks it is the fixing afterwards.

Random is not the same as fair

A hat draw is random in the only sense that matters for the draw itself: every name has the same chance of landing anywhere. But a teacher does not actually want pure randomness. She wants two things at once: groups that nobody chose, and two particular students kept apart. Pure randomness cannot promise the second one. With 28 names going into 7 groups of 4, the odds that one specific pair lands together are roughly one in nine — not rare at all, and with two chatty pairs to separate, the chance that at least one of them lands together is closer to one in five. So the hat keeps producing the exact result you cannot use, and every hand swap after it quietly undoes the fairness the draw was supposed to guarantee.

The way out is to change the order: put the rule in before the draw, not after it. Decide first which pairs must not share a group, then shuffle only inside that rule. The groups are still random — nobody picks who goes where — but the shuffle is only allowed to produce arrangements where the pairs are apart. Nothing is swapped afterwards, because there is nothing left to fix.

"Fair" here means two concrete things, and both are checkable: every group has the same size, and the forbidden pairs are in different groups. That is the test I ran.

The test: 28 names, two pairs, three shuffles

I made up a class of 28 fictional students — invented names, one per line, under a header that just reads Name. The title of this post says two students; my test used two pairs, four students in total: Chloe Bennett must not share a group with Dylan Marsh, and Zoe Alvarez must not share one with Caleb Reed. I ran three shuffles and checked four things each time: both pairs apart, 7 groups of 4, all 28 names present exactly once. Tested 2026-11-20.

The roster went in as a file, roster-28-class.txt — the header plus 28 names, 352 bytes. The header was recognised, not counted as a person: the "Name column" dropdown read "Name". One thing to know: after the file loads, the tool only says "File read." There is no count on screen. The 28 only shows up later, in the result summary.

A 28-name class roster pasted into the group maker before splitting it into random groups

On the Groups tab I changed "Divide people by" from "Number of groups" (default 2) to "People per group" and set "People per group" to 4. "Handle extra people" stayed on its default, "Balance evenly", and "Balance by category" stayed on "Do not balance". Then the two pairs, in the field labelled "Pairs that must stay apart (one pair per line, separated by a comma)": Chloe Bennett, Dylan Marsh on one line, Zoe Alvarez, Caleb Reed on the next. One warning from my own first attempt: pasting both pairs at once lost the line break and merged them into a single line — "Chloe Bennett, Dylan MarshZoe Alvarez, Caleb Reed". Typing them in worked. Check that you see two lines before you go on, because a merged line is not two rules.

Two pairs listed as keep-apart rules so the chatty students never share a group

The first shuffle came back "28 people · 7 groups (4 / 4 / 4 / 4 / 4 / 4 / 4 people) · requested group size: 4". Chloe Bennett landed in Group 7 and Dylan Marsh in Group 3. Zoe Alvarez landed in Group 2 and Caleb Reed in Group 1. All seven groups had exactly 4, and all 28 names appeared once.

The second shuffle changed every group — and both pairs stayed apart again. Chloe Bennett in Group 3, Dylan Marsh in Group 7. Zoe Alvarez in Group 4, Caleb Reed in Group 2. Still 4 in every group, still all 28 names once.

Seven random groups of four with the two keep-apart pairs in different groups

The third shuffle changed the groups again, and both pairs stayed apart a third time. Chloe Bennett in Group 1, Dylan Marsh in Group 4. Zoe Alvarez in Group 2, Caleb Reed in Group 5. The full third result: Group 1 Chloe Bennett, Hugo Ferreira, Grace Nakamura, Jack Sullivan; Group 2 Zoe Alvarez, Ethan Brooks, Amara Diallo, Sofia Patel; Group 3 Daniel Reyes, Felix Bauer, Isla Moreno, Owen Fitzgerald; Group 4 Dylan Marsh, Sam Whitaker, Layla Hassan, Freya Lindqvist; Group 5 Caleb Reed, Nora Haddad, Noah Kim, Henry Walsh; Group 6 Elena Petrova, Mia Tanaka, Maya Chen, Lucas Meyer; Group 7 Oliver Grant, Leo Park, Ruby Osei, Ava Novak. Three shuffles, zero forbidden pairs together.

The CSV matches the screen exactly. groups-seating-draw.csv holds seven rows, one per group, each row a quoted group name followed by its four members — "Group 1","Chloe Bennett","Hugo Ferreira","Grace Nakamura","Jack Sullivan" through Group 7 — in the same order as the third shuffle on screen. I opened the file and checked it row by row against the screen: same groups, same members, same order, all 28 names. The file is 481 bytes, with no header.

The downloaded CSV of the seven groups, ready to print or share with the class

One detail worth knowing before you trust a screenshot of the result: the names in the result box are separated by tabs, so on screen "Leo Park" and "Ruby Osei" read as "Leo ParkRuby Osei". The values are correct — the CSV splits them cleanly — but don't read the group list off a screenshot. Open the CSV if a name looks glued to the next one.

The other ways to split a class

Drawing names from a hat works, and it is the classic answer. But when the chatty pair lands together, you swap them by hand — and the swap is no longer random. Drawing 28 names into 7 groups of 4 also takes a while by hand.

Shuffling with Excel's RAND function works too. But a formula cannot enforce a keep-apart rule, so every time the forbidden pair lands together you reshuffle and check by eye. The three-shuffle check I did above becomes manual work.

Pure random group tools — the top search results like seatingplan, classbox, and thescience360 — work, and they are the first thing most teachers find. But they only shuffle. Keeping two students apart is left as a manual step after the draw, which is the exact step that breaks the randomness.

A spin-wheel guide like spinyourpick works the same way: it tells you to separate the pair by hand after the spin. The separation is still yours to do, and to check, every time you make groups.

The browser tool I tested sits in the narrow case between these: the roster already exists as one name per line, there are one or two pairs who must not share a group, and you want the shuffle checked and saved as a CSV you can print or hand out.

What it won't do

  • You can't get a shuffle back. Every "Shuffle again" makes a new result, and the old one can't be reproduced. When a shuffle looks right, save the CSV before you shuffle again.
  • Many tangled keep-apart rules can fail. The page says the tool searches within a limited number of attempts and stops with a notice if it can't find an arrangement. My two pairs worked three times out of three, but if your rules are heavily tangled, expect to cut a rule or change the group count and try again.
  • Duplicate names can't be told apart. Add a class or a number to each duplicate before you use the list — the page says so, and my list had no duplicates to test it with.
  • The remainder default is "Balance evenly". My 28 divides evenly by 4, so I didn't test the remainder. If your class doesn't divide evenly, change "Handle extra people" before you generate the result — the default spreads the extra students across the groups.
  • Your list stays in your browser. "Keep the list in your browser; it is not sent to a server." Nothing is uploaded, and the file you loaded is not changed.
Try the toolGroups, Seating & Name DrawCreate groups, assign classroom seats, or draw names from a list. List pairs who mustn’t share a group, lay out seats in a classroom grid, or draw presenters and chore duty without repeats.loopyti.com

When the rules can't all be satisfied

A search that comes back empty is not a dead end — it is the tool telling you the constraints don't fit the shape of the class. The page is direct about this: it searches a limited number of times and stops with a notice if it can't find an arrangement that meets all the rules.

The usual cause is too many rules tangled together. Two pairs in a class of 28 worked three times out of three, but every pair you add shrinks the space of valid arrangements, and pairs that chain together — A must avoid B, B must avoid C, C must avoid A — shrink it fastest. The fix is to loosen something: drop the least important pair, or change the group count so the groups are bigger and the pairs have more room to land apart. A group of 6 gives a forbidden pair far more places to avoid each other than a group of 3 does.

The other thing to settle first is whether the rules themselves are right. A pair listed twice by accident, a name misspelled so the rule points at nobody, a student who left the class but is still on the roster — any of these makes the search chase an arrangement that doesn't exist. Check the pairs list the way you would check the roster: two lines, the right names, no merged line.

And save the CSV the moment a shuffle looks right. A good arrangement is only yours once it is saved — shuffle again and it is gone, and no rule will bring it back.