【发布时间】:2014-12-24 06:31:55
【问题描述】:
我有五个巨大的数组,每个数组都用字符串填充,每个数组/列表中有不同数量的项目。
这是列表的一个示例:
List 1
"Jeffrey the Great",
"Bean-man",
"Joe",
"Charles",
"Flamur",
"Leka",
"the defender of men",
List 2
"awesome",
"claustrophobic",
"sad",
"very masculine",
"stinky",
"outrageous",
"underage",
"endangered",
"filthy",
"kinda smooth",
"overly threatening",
List 3
"corpse",
"skeleton",
"average joe",
"mafia boss",
"murderer",
"butcher",
"dog",
"muslim",
"fish salesman",
List 4
"impregnate",
"punch",
"eat",
"kill",
"hunt down",
"outrun",
"touch",
List 5
"Steve",
"Stalin",
"el Chupacabra",
"everyone",
"a donut",
"a fish",
"the Americans",
"your neighbors",
我想找出这五个列表的所有可能组合 例如:
Jeffery the Great, awesome, corpse, impregnate, steve
Bean-man, awesome, corpse, impregnate, steve
Joe, awesome, corpse, impregnate, steve
Charles, awesome, corpse, impregnate, steve
Jeffery the Great, claustrophobic, corpse, impregnate, steve
Bean-man, claustrophobic, corpse, impregnate, steve
Joe, claustrophobic, corpse, impregnate, steve
Charles, claustrophobic, corpse, impregnate, steve
...对于每个列表中的每个项目,依此类推。
每个组合必须包含每个数组/列表中的一个。 我不想生成可能的组合,只有每个可能组合的 count! 示例:
List 1
a
b
c
List 2
1
2
3
结果:
9 possible combinations
任何线索我怎么能找到这个?
【问题讨论】:
-
不是5个长度的乘积吗?
-
不就是(列表 1 中的项目总数)*(列表 2 中的项目总数)吗?
标签: javascript arrays