从五个项目数组中找出可能组合的总数

Finding out the total number of possible combinations from five arrays of items

本文关键字:组合 数组 五个 项目数 项目      更新时间:2023-09-26

我有五个巨大的数组,每个数组都填充着字符串,每个数组/列表中都有不同数量的项目。
以下是列表的示例:

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;