the-honk/languages/python/chunkArray.py
2022-04-08 16:50:38 +01: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))