如何从6组数字中获得所有可能的6个数字组合 [英] How do I get all possible 6 number combination from a 6 set of numbers

查看:135
本文介绍了如何从6组数字中获得所有可能的6个数字组合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以使用Excel(xls或xlsx)或任何其他方便的语言创建和转发程序,这可以创建下面6组数字中6个数字的所有可能组合。组合应该是递增的数字,并且组合中不会重复数字。每组中的一个数字被挑选以形成六个的组合。即组合的第一个数字应该来自第一组,第二组来自第二组......第六组来自第六组。第一个数字应该低于第二个,第二个应该低于第三个....第五个数字应该低于第六个。



示例组如下:



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



第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。



第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。



第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。



第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。



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


我在google上搜索了上述解决方案,但确实如此没有得到任何满意的答案。如果您可以创建一个具有上述要求的Excel文件,请将它转发给我。

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.

推荐答案

对不起,我们不会为您做功课。这对你没有好处,因为如果你没有写它,你如何解释你的代码在做什么。幸运的是,如果您暂停并暂时考虑一下这些要求,这是一个相对简单的任务。如果我正在解决这个问题,我首先要将需求分解为小语句 - 例如,下一级别的数字必须大于此级别的数字 - 所以,这会告诉我,我可能想要排序每个组按升序排列。



蛮力方法是使用循环从第一行获取每个值,然后在下一行中查找更大的值(继续浏览关卡,直到你无法组合或使用数字)。您还需要考虑到较低级别的每个循环迭代也必须执行循环。
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.


这篇关于如何从6组数字中获得所有可能的6个数字组合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆