In reply to Todd Friedlander.

I think this is a great programming problem. The language that I am using is SAS (specifically, the SAS/IML matrix language), but you can take the ideas and implement them in any language such as python or Java. Be sure the language gives you access to a library that generates permutations. Good luck!