[英]How to generate a file with all possible 12 character letter/number combinations?
I have been struggling with this for some time, and I can't even figure out where could I start with it. 我已经为此苦苦挣扎了一段时间,甚至不知道该从哪里开始。 I am trying to create a program that is going to generate a lot of random (I could call them serials). 我正在尝试创建一个程序,该程序将产生大量随机性(我可以称其为序列号)。 Limit would be from letter AZ on english uppercase alphabet and numbers from 0-9. 限制为英文大写字母的字母AZ和0-9的数字。
Something like website application at this page http://www.random.org/strings/ 类似于此页面上的网站应用程序http://www.random.org/strings/
but 但
I would like it to create "all" combinations, none same, of letters and numbers, and save them to text file. 我希望它创建字母和数字的“所有”组合(不完全相同),并将它们保存到文本文件中。 I think there are around 200k+ combinations. 我认为大约有20万多种组合。
They would be 12 characters. 他们将是12个字符。 Example: 例:
I would like to create it in C# if it is possible, but I have no idea where should I even start. 如果可以的话,我想用C#创建它,但是我不知道我应该从哪里开始。 I'm browsing google and similar projects for around a week, and I need it as university project. 我正在浏览google和类似项目大约一个星期,我需要它作为大学项目。 If someone would help I would be very happy. 如果有人可以帮我,我会很高兴。
Hehe.. if you have the time! 呵呵..如果您有时间!
Asked yesterday, seen a great solution by LB here: 昨天被问到,在这里看到了LB的一个很好的解决方案:
How to get all the possible 3 letter permutations? 如何获得所有可能的3个字母排列?
His simple solution, just change the alphabet: 他的简单解决方案,只需更改字母即可:
var alphabet = "abcdefghijklmnopqrstuvwxyz1234567890";
var query = from a in alphabet
from b in alphabet
from c in alphabet
from d in alphabet
from e in alphabet
from f in alphabet
from g in alphabet
from h in alphabet
from i in alphabet
from j in alphabet
from k in alphabet
from l in alphabet
select "" + a + b + c + d + e + f + g + h + i + j + k + l;
foreach (var item in query)
{
Console.WriteLine(item);
}
A more advanced answer might be the CartesianProduct 一个更高级的答案可能是笛卡尔积
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.