Math & Numbers
生成多重集的排列、组合与子集,自动去重并按字典序输出:排列用 next_permutation,精确计数 n!/Π(mᵢ!);组合生成不同的 k-子多重集,计数为 Π(1+x+…+x^mᵢ) 中 x^k 的系数(元素互异时即 C(n,k));子集枚举所有子多重集,计数 Π(mᵢ+1)(互异时 2ⁿ),含空集。最多 12 个元素,展示上限 200 条但计数始终精确;组合模式要求 1 ≤ k ≤ n。经典例:[A, A, B] 的排列 → 3!/2! = 3 个(AAB、ABA、BAA);[A, A, B] 的子集 → (2+1)(1+1) = 6 个。
用三种语言从你的代码中调用此工具。
curl -X POST 'http://127.0.0.1:3003/zh/api/tools/combinatorial-generation' \
-H 'Content-Type: application/json' \
-d '{"mode":"permutations","items":"A, B, C","k":0,"decimalPlaces":4}'以 JSON 形式 POST 提交输入参数。文件类型参数需先单独上传。
POST http://127.0.0.1:3003/zh/api/tools/combinatorial-generation| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| mode | select | 是 | — |
| items | text | 是 | 1–12 items separated by commas or spaces; duplicates like 'A, A, B' are supported and only distinct results are generated. |
| k | number | 否 | How many items each combination holds; ignored in the permutations and subsets modes. |
| decimalPlaces | number | 否 | — |
文本结果
{
"result": "Processed text content",
"error": "Error message (optional)",
"message": "Notification message (optional)",
"metadata": {
"key": "value"
}
}将此工具加入你的 Model Context Protocol 服务,让 AI 智能体可以列出并调用它。
将以下内容加入你的 MCP 客户端配置:
{
"mcpServers": {
"elysiatools-combinatorial-generation": {
"name": "combinatorial-generation",
"description": "生成多重集的排列、组合与子集,自动去重并按字典序输出:排列用 next_permutation,精确计数 n!/Π(mᵢ!);组合生成不同的 k-子多重集,计数为 Π(1+x+…+x^mᵢ) 中 x^k 的系数(元素互异时即 C(n,k));子集枚举所有子多重集,计数 Π(mᵢ+1)(互异时 2ⁿ),含空集。最多 12 个元素,展示上限 200 条但计数始终精确;组合模式要求 1 ≤ k ≤ n。经典例:[A, A, B] 的排列 → 3!/2! = 3 个(AAB、ABA、BAA);[A, A, B] 的子集 → (2+1)(1+1) = 6 个。",
"baseUrl": "http://127.0.0.1:3003/mcp/sse?toolId=combinatorial-generation",
"command": "",
"args": [],
"env": {},
"isActive": true,
"type": "sse"
}
}
}连接到 SSE 端点后,列出已开放的工具:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}通过工具 id 调用,参数由其参数表构建:
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "combinatorial-generation",
"arguments": {
"mode": "permutations",
"items": "A, B, C",
"k": 0,
"decimalPlaces": 4
}
}
}有问题或反馈?请联系 [email protected]