the-honk/python/chunkArray.py
2024-10-09 18:02:48 +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))