获取所有可能的字的组合 [英] Get all possible word combinations

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

问题描述

我有n个字列表(比方说26)。现在,我希望得到所有可能的组合的名单,但每次最多每行K字(假设5)

I have a list of n words (let's say 26). Now I want to get a list of all possible combinations, but with a maximum of k words per row (let's say 5)

所以,当我的词列表是:AAA,BBB,......,ZZZ
我想:

So when my word list is: aaa, bbb, ..., zzz I want to get:

aaa
bbb
...
aaabbb
aaaccc
...
aaabbbcccdddeeefff
aaabbbcccdddeeeggg
...

我想使它变量,这样它会与任何n或k值为工作。
不应该有一句话是两次,需要采取(即使有非常多)。

I want to make it variable, so that it will work with any n or k value. There should be no word be twice and every combinations needs to be taken (even if there are very much).

我怎么能做到这一点?

编辑:

感谢您的答案。这不是一项任务。是的,只是我忘了我的密码的组合,我想确保我的所有组合进行测试。虽然我还没有26密码部分,但是这使得它更容易解释,我想要的东西。

Thank you for your answers. It is not an assignment. Is is just that I forgot the combinations of my password and I want to be sure that I have all combinations tested. Although I have not 26 password parts, but this made it easier to explain what I want.

如果有其他人同样的问题,这个环节可能是有益的:结果
生成的C#文字组合排列

If there are other people with the same problem, this link could be helpfull:
Generate word combination array in c#

推荐答案

您可以看看的

不过,如果你需要得到大量的组合(在数以千万计的),你应该使用懒评价组合的产生。

However, if you need to get large numbers of combinations (in the tens of millions) you should use lazy evaluation for the generation of the combinations.

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

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