the-honk/python/chunkArray.py
2023-01-26 13:04:21 +00:00

11 lines
245 B
Python

def chunkArray(array, chunkCount):
chunks = []
for i in reversed(range(1, chunkCount + 1)):
splitPoint = len(array) // i
chunks.append(array[:splitPoint])
array = array[splitPoint:]
return chunks
print(chunkArray([1,2,3,4,5,6], 4))