[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Partitioning a list

On Tue, 21 Aug 2018 14:36:30 -0700, Poul Riis wrote:

> I would like to list all possible ways to put N students in groups of k
> students (suppose that k divides N) with the restriction that no two
> students should ever meet each other in more than one group. I think
> this is a classical problem 

If its a classical problem, there should be many solutions written for 
other languages. Take one of them and port it to Python. (We can help 
with the Python part if needed.)

I've never come across it before. I think the restriction makes it a HARD 
problem to solve efficiently, but I've spent literally less than two 
minutes thinking about it so I could be wrong.

With no additional restriction it sounds like a classical permutations or 
combinations problem. Check out the combinatoric iterators functions in 
the itertools module:


Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson