Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can you create and forward me the program in Excel (xls or xlsx) or any other convenient language, which can create all possible combinations of 6 numbers out of 6 group of numbers below. Combinations shoud be in ascending numbers and no repeatation of numbers in a combination. One number from each group be picked to form combination of six. i.e 1st number of the combination should be from first group and 2nd from 2nd group ....sixth from sixth group. 1st number should be lower than 2nd, 2nd should be lower than 3rd....5th number should be lower than 6th.

Examples groups as follows:

Group 1: 02, 01, 05, 04, 07, 10, 11, 03, 08, 06, 15, 09, 16, 14, 22, 21, 09, 13.

Group 2: 12, 08, 06, 13, 20, 21, 14, 28, 18, 19, 07, 09, 10, 11, 17, 22, 24, 04, 23, 15, 02, 34, 03, 27, 05.

Group 3: 24, 15, 30, 22, 31, 17, 14, 19, 27, 26, 09, 08, 32, 35, 16, 29, 23, 39, 11, 10, 21, 28, 25,20, 18, 33, 38, 34.

Group 4: 31, 33, 29, 16, 24, 38, 19, 35, 32, 23, 30, 37, 21, 27, 34, 41, 43, 40, 25, 17, 28, 11, 26, 14, 18, 39, 36.

Group 5: 40, 44, 39, 42, 41, 37, 30, 45, 36, 38, 31, 35, 20, 34, 27, 33, 24, 28, 18, 12, 48, 21, 46, 47, 43, 26.

Group 6: 47, 48, 49, 44, 45, 42, 43, 46, 40, 38, 35, 37, 32, 41, 39, 36, 25, 24, 28.

I have searched on google for above solution but did not get any satisfactory answer. If you can create an excel file with above requirement kindly forward it to me please.
Posted

1 solution

I'm sorry, but we won't do your homework for you. That would be doing you no favours because how could you explain what your code is doing if you didn't write it. Fortunately for you, this is a relatively trivial task if you just pause and think about the requirements for a little while. If I were tackling this, I would start by breaking the requirements into small statements - for instance, the number at the next level must be greater than the one at this level - so, this would suggest to me that I would probably want to sort each group into ascending order.

A brute force approach would be to use loops to get each value from the first row and then find values in the next row that are greater (keep going through the levels until you either can't make a combination or you use the numbers). You will also want to take into account that each loop iteration at a lower level will have to perform looping as well.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900