views:

62

answers:

1

This is one of those, " I wish I had listened better, retained more of my math class info..", questions. I did this with brute force, but I know there's a better more correct way of accomplishing this.

Given a 4 x 4 array of stations, and 8 groups(a-h). How to fill the array with group pair combinations so each pair(ab, ba) occurs only once, and each group occurs only once in each row and column? (If a is part of a pair in 1,1, it can no long appear in a grouping in row 1 or column 1)

Of course not all possible groupings happen.

+1  A: 

Yes, I think brute force is the way to go, though you can invest into trimming branches smarter if you wish.

ilya n.
Brute force did get the job done, now it's an intellectual exercise, chance to learn something.
dverespey
Sure, but I'm certainly better at math than median programmer and I still don't see any significant optimizations. But if you had 4 groups, I think there's a theory about "Magic Squares".
ilya n.
After more checking your're correct, the answer is brute force...thanks
dverespey