How do I write a c program to display all possible combinations from two arrays depending on filters?
I have 8 arrays in total, I have to write a program such that I find all possible combinations such that, There are total 14 elements in the final display, each chosen in following manner,
Each of the eight arrays can contain any number of elements (atleast to fulfill basic minimum conditions), but the total number of elements in each of arrays will be 28.
These elements will have numerical value one among (8.5, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.5) and one character string as its variable name
choose "2" elements from array 1 and array 2 ; final arrays should contain exactly two from this group
choose "3-6" elements from array 3 and array 4; final arrays should contain at-least 3 from this group
choose "2-4" elements from array 5 and array 6; final arrays should contain at-least 2 from this group
choose "3-6" elements from array 7 and array 8; final arrays should contain at-least 3 from this group
And total of all elements of final arrays should be less than or equal to 150.
And less than total 9 elements from arrays A1, A3, A5, A7
And less than total 9 elements from arrays A2, A4, A6, A8
I cannot get started with the algorithm itself. Please help.
following is the sample dataset
A1 = [Tom (8.5)]
A2 = [Ron (11.5), Ronny (12.5)]
A3 = [Abbie (12), Abby (11.5), alexa (11), alex (11), bert(11)]
A4 = [Lex (10), Luthor(10.5), thor(9.5), loki(10.5), jack(11), jackie(11.5)]
A5 = [Ali (11.5) Lee (10.5), nessy (11), Nes (10.5)]
A6 = [Alfie (11), Ala (11), Gail(11.5)]
A7 = [Andy (12), Nanny (10.5), nancy(8.5), bernie(9)]
A8 = [Casie (12.5), Ryan (10), Ben(9.5)]
And ouput will be arrays of 14 names from above according to the conditions
For eg:
output array1 : [tom, ron, abbie, abby, alexa, loki, jackie, Ali, nes, casie, ryan, ben, nancy, bernie]
The array1 has total less than 150, it has 2 from array 1 and 2, atleast 3 from array 3 and 4, atleast 2 from array 5 and 6, atleast 3 from array 7 and 8, and less than 9 elements from elements of A1, A3, A5, A7 and less than 9 elements from elements of A2, A4, A6, A8 Thus satisfying each and every condition;
Similarly Output should display all such arrays
What I have tried:
I tried with the total number of arrays that will be possible first, except the sum less than equal to feature
I tried to display final array but was unsuccessful in implementing the total less than or equal to filter and I was not able to use name variables and their numerical value at once