partition_integer_by_ratio

mathtools.partition_integer_by_ratio(n, ratio)

Partitions positive integer-equivalent n by ratio.

>>> mathtools.partition_integer_by_ratio(10, [1, 2])
[3, 7]

Partitions positive integer-equivalent n by ratio with negative parts:

>>> mathtools.partition_integer_by_ratio(10, [1, -2])
[3, -7]

Partitions negative integer-equivalent n by ratio:

>>> mathtools.partition_integer_by_ratio(-10, [1, 2])
[-3, -7]

Partitions negative integer-equivalent n by ratio with negative parts:

>>> mathtools.partition_integer_by_ratio(-10, [1, -2])
[-3, 7]

More examples:

>>> mathtools.partition_integer_by_ratio(10, [1])
[10]
>>> mathtools.partition_integer_by_ratio(10, [1, 1])
[5, 5]
>>> mathtools.partition_integer_by_ratio(10, [1, -1, -1])
[3, -4, -3]
>>> mathtools.partition_integer_by_ratio(-10, [1, 1, 1, 1])
[-3, -2, -3, -2]
>>> mathtools.partition_integer_by_ratio(-10, [1, 1, 1, 1, 1])
[-2, -2, -2, -2, -2]

Returns result with weight equal to absolute value of n.

Returns list of integers.