from math import floor
def division_boundaries(length, parts):
p = floor(length / parts)
r = 0
offsets = []
for _ in range(parts):
offsets.append([r, r + p])
r += p
offsets = [[x + 1, y] for x, y in offsets]
offsets[0][0] = 0
offsets[-1][1] = length - 1
return offsets
# Example:
part_indices = division_boundaries(15, 3)
# -> [[0, 5], [6, 10], [11, 14]]
# The method will get length of array and number of parts
# that the array will be divded into. Output will be indices
# of division.
# Thus indices can be used to get any part of array.
# Get first part of list:
# thelist[part_indices[0][0]:part_indices[0][1]]