创建 2 个字符数组的所有单词变体
我有 2 个字符串集合 例如:
List<string> one = new List<string>;
one.Add("a");
one.Add("b");
one.Add("c");
List<string> two = new List<string>;
two.Add("x");
two.Add("y");
two.Add("z");
我想做的是创建一个可以由此创建的所有单词变体的列表。 但我只想创建 4 个字符的单词! 例如,我想要这样的词:“
axax (from one[1],two[1],one[1],two[1])
ayax (from one[1],two[2],one[1],two[1])
azax (from one[1],two[3],one[1],two[1])
最终得到
czcz (from one[3],two[3],one[3],two[3])
任何有关生成此内容的最快和最佳方式的建议”
I have 2 collections of caracter string
ex:
List<string> one = new List<string>;
one.Add("a");
one.Add("b");
one.Add("c");
List<string> two = new List<string>;
two.Add("x");
two.Add("y");
two.Add("z");
What i would like to do is create a list of all the variations of words that can be created from this.
But i only want to create 4 character words!
so for example i would want words like
axax (from one[1],two[1],one[1],two[1])
ayax (from one[1],two[2],one[1],two[1])
azax (from one[1],two[3],one[1],two[1])
eventually getting to
czcz (from one[3],two[3],one[3],two[3])
Any suggestions on the fastest and best way to generate this
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我怀疑这个解决方案是否会赢得任何速度奖,但它应该相当快:
I doubt this solution will win any speed awards, but it should be reasonably quick: