mathtools.partition_integer_into_thirds

abjad.tools.mathtools.partition_integer_into_thirds(n, smallest='middle', biggest='middle')

Partition positive integer n into left, middle, right parts.

When n % 3 == 0, left == middle == right:

abjad> mathtools.partition_integer_into_thirds(9)
(3, 3, 3)

When n % 3 == 1, set biggest part to biggest:

abjad> maththools.partition_integer_into_thirds(10, biggest = 'left')
(4, 3, 3)
abjad> maththools.partition_integer_into_thirds(10, biggest = 'middle')
(3, 4, 3)
abjad> maththools.partition_integer_into_thirds(10, biggest = 'right')
(3, 3, 4)

When n % 3 == 2, set smallest part to smallest:

abjad> maththools.partition_integer_into_thirds(11, smallest = 'left')
(3, 4, 4)
abjad> maththools.partition_integer_into_thirds(11, smallest = 'middle')
(4, 3, 4)
abjad> maththools.partition_integer_into_thirds(11, smallest = 'right')
(4, 4, 3)

Raise TypeError on noninteger n:

abjad> mathtools.partition_integer_into_thirds(7.5)
TypeError

Raise ValueError on nonpositive n:

abjad> mathtools.partition_integer_into_thirds(-1)
ValueError

Previous topic

mathtools.partition_integer_into_halves

Next topic

mathtools.partition_integer_into_units

This Page