You have (up to 100) distinct sets of (2-4) numbers. The order of the sets or numbers in the sets does not matter. The highest number relates to the number of sets and goes up to 30. Like:
{1 2 3 4} {1 2 3 5} {1 2 3} {1 2 4 5} {6 2 4} {6 7 8 9} {6 7 9} {7 8 9} {2 4 8 9}
The goal is, to arrange these sets in a particular order, where two successive sets do not contain a common number. That is
{1 2 3 4} {2 4 8 9}
is bad (because of the 2). And
{1 2 3 4} {6 7 8 9}
is good.
Of course, especially in the given example, this is not possible for the whole set of sets. But the number of sets which violate the rules should approximately be minimized.
I assume, some brute-force + scoring algorithm is not feasible with the relatively large number of sets. Do you have any other ideas or hints for a deterministic algorithm to solve this problem?
Do you think, a shuffle + score algorithm could find decent solutions (in some restricted time frame, like 5 seconds, standard computer)?