the-honk/python/chunkArray.py

12 lines
245 B
Python
Raw Permalink Normal View History

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
2024-10-09 17:02:45 +00:00
print(chunkArray([1,2,3,4,5,6], 4))