小编OhN*_*oez的帖子

什么是最像Ruby的方式生成3个正整数的每个独特组合,最多可加100

条件

a + b + c = 100
a,b,c positive integers or 0
Run Code Online (Sandbox Code Playgroud)

期望的输出:

[
  [0,0,100],
  [0,1,99 ],
  ... # all other permutations
  [99,1,0 ],
  [100,0,0]
]
Run Code Online (Sandbox Code Playgroud)

Stackoverflow说我的帖子没有太多的上下文来解释代码部分.你同意吗?(这是填充文本以满足其要求)

ruby combinations function permutation

6
推荐指数
1
解决办法
406
查看次数

标签 统计

combinations ×1

function ×1

permutation ×1

ruby ×1