相关疑难解决方法(0)

用于整数分区的优雅Python代码

我试图编写代码来解决标准的整数分区问题(维基百科).我写的代码很乱.我需要一个优雅的解决方案来解决问题,因为我想改进我的编码风格.这不是一个家庭作业问题.

python algorithm

32
推荐指数
6
解决办法
3万
查看次数

Algorithm to generate all unique permutations of fixed-length integer partitions?

I'm searching for an algorithm that generates all permutations of fixed-length partitions of an integer. Order does not matter.

For example, for n=4 and length L=3:

[(0, 2, 2), (2, 0, 2), (2, 2, 0),
 (2, 1, 1), (1, 2, 1), (1, 1, 2),
 (0, 1, 3), (0, 3, 1), (3, 0, 1), (3, 1, 0), (1, 3, 0), (1, 0, 3),
 (0, 0, 4), (4, 0, 0), (0, 4, 0)]
Run Code Online (Sandbox Code Playgroud)

I bumbled about with integer partitions + permutations for …

algorithm integer data-partitioning

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

标签 统计

algorithm ×2

data-partitioning ×1

integer ×1

python ×1