Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
As I had pointed out earlier, this is a difficult problem to solve in general.
I have managed to find a nice description of the problem in sections VI.8 and V.8 in the CRC Handbook of Combinatorial Designs by Colbourn and Dinitz.