Depending on how big the list is, prime numbers might come in handy. I once wrote a computerized Jotto game in which the computer needed to find words that contained a specific combination of letters and excluded others, while remaining indifferent to yet others. By assigning a prime number to each letter of the alphabet, the computer could multiply up with a product for a certain word, and see if that word mod the product of a different word = 0.
If you assign prime numbers to the possible values of list # 2, then compare the products of the values in the various rows, you should be able to extract common denominators that will be helpful in compiling this list.
The problem is that this works only for small sets of possible values. In my Jotto game, there were only 26 different prime number values, and any word could only have been a product of 5…so the maximum value for a word was 5,717,264,681. If you have more potential values, or each value from list 1 could correlate to a large number of values in list 2, then the math will quickly get too big for standard long integers.
A solution to what? What is the precise problem here?
If I understand the OP, the objective is to generate the minimal number of sets, each member of which is a (row-group, column-group) pair where a given row and column specified in a given member are not both in another member, and where all the row/column combinations exactly cover the row/column mapping that you start out with.
Yeah, I’m in Melbourne, so everybody’s posting while I’m asleep (and vice-versa!)
It looks like there’s a lot of helpful suggestions in here … thanks everyone, I’m still processing all the various bits of info (my thinking time on this problem is currently mostly restricted to “Mondays and Wednesdays while at work” or “those brief snatched moments of the day when the baby’s asleep and I’m not”
)
Just to expand on the original problem, the specific application in this instance is to send mails to particular users from a set of users, with attached files from a set of possible attachments, where any one user is likely to want some or all of the same attachments as another user. The thing I am trying to minimise is the number of mails sent (for other bizarre and complex reasons that I won’t get into at the moment … we’ll just take it as a constraint of the problem here
)
So in my original example, (A,B,C…) is the set of users, (1,2,3…) is the set of possible file attachments and “A,B => 1,2” means A and B are sent one mail with files 1 and 2 attached.
Punoqllads’ algorithm is looking good at the moment … it’s not actually essential to get the true minimal solution, the goal is just to make it reasonably good, and sensible-looking to the users
Thanks All!