从五个项目数组中找出可能组合的总数
Finding out the total number of possible combinations from five arrays of items
我有五个巨大的数组,每个数组都填充着字符串,每个数组/列表中都有不同数量的项目。
以下是列表的示例:
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
。依此类推,适用于每个列表中的每个项目。
每个组合必须包含每个数组/列表中的一个。我不想生成可能的组合,只生成每个可能组合的计数!例:
List 1
a
b
c
List 2
1
2
3
结果:
9 possible combinations
任何线索我怎么能找到这个?
简单的排列和组合数学和JavaScript
var num_of_combination = list1.length * list2.length * list3.length * list4.length * list5.length;
相关文章:
- 根据id将json数组组合为一个json数组
- jqueryeasyui使用子数组组合数据
- javascript数组中条目的成对组合
- 将数组中的所有数字组合相加
- JavaScript算法,提供每种可能的项目组合,并将它们存储在数组中
- 将两个数组合并为一个具有键值关系的数组
- 如何将数组的对象与同一索引组合
- 将对象隐藏到组合/对象数组
- 为什么我的jQuery.map不能在这里组合我的数组
- 组合/匹配数组
- Javascript数组添加 - 所有组合
- 使用具有特定条件的 lodash 添加和组合对象数组中的重复项
- 将数组组合到一个对象中
- Javascript将JSON放入数组中,组合并在其他地方使用
- 在 JavaScript 对象中组合来自不同属性的数组项
- JavaScript for in - 从主对象获取、组合和处理数组
- 在数组中的一组标识符中组合 2 个值
- 组合 JavaScript 数组
- 在 JavaScript 中组合两个字符串数组
- 使用数组和对象的组合循环访问数据