A while back I wanted to build the classic "paste a list of names, get N even groups" tool — the kind of thing every teacher and event organizer has needed at some point. I assumed it would basically be a Fisher-Yates shuffle plus Array.slice in a loop, maybe an hour of work.
Then I actually thought about what people ask for when they say "randomly group my class." They don't mean random. They mean "randomly, except don't put the two kids who fight in the same group" or "spread the interns evenly across every table" or "the three team leads all need to end up in different groups." The moment you add a single constraint, true randomness becomes the enemy, not the feature. So the tool I ended up shipping has no Math.random() anywhere in the grouping logic at all. It's a deterministic, rule-aware placement algorithm dressed up as a "smart" shuffle.
Parsing a pasted list is messier than it looks
Before anything can be grouped, the raw textarea has to become a clean list of unique names. People paste from Excel, from a Google Doc, from a group chat — so the delimiter could be a newline, a comma, a full-width Chinese comma, a semicolon, or just whitespace:
function parseInput() {







