相关疑难解决方法(0)

从n返回k个元素的所有组合的算法

我想写一个函数,它将一个字母数组作为参数,并选择一些字母.

假设您提供了8个字母的数组,并希望从中选择3个字母.然后你应该得到:

8! / ((8 - 3)! * 3!) = 56
Run Code Online (Sandbox Code Playgroud)

数组(或单词)返回,每个包含3个字母.

algorithm combinations

551
推荐指数
23
解决办法
43万
查看次数

找到所有可能的组合

我之前提过这个问题但是关于另一种编程语言.

假设我有几个词根,前缀和后缀.

roots = ["car insurance", "auto insurance"]
prefix = ["cheap", "budget"]
suffix = ["quote", "quotes"]
Run Code Online (Sandbox Code Playgroud)

Python中是否有一个简单的函数,它允许我构造三个字符向量的所有可能组合.

所以我想要一个列表或其他数据结构,它返回每个字符串的所有可能组合的以下列表.

cheap car insurance quotes
cheap car insurance quotes
budget auto insurance quotes
budget insurance quotes
...
Run Code Online (Sandbox Code Playgroud)

python list

2
推荐指数
1
解决办法
1397
查看次数

标签 统计

algorithm ×1

combinations ×1

list ×1

python ×1