2019-1: Chunky Monkey
Write a function that, given a scalar or vector as the right argument and a positive (>0) integer chunk size n
as the left argument, breaks the array's items up into chunks of size n
. If the number of elements in the array is not evenly divisible by n
, then the last chunk will have fewer than n
elements.
π‘ Hint: The partitioned enclose function XβY
could be helpful for this problem.
Examples:
3 (your_function) β³9 β ]Box on is used to display the result
βββββββ¬ββββββ¬ββββββ
β1 2 3β4 5 6β7 8 9β
βββββββ΄ββββββ΄ββββββ
3 (your_function) β³11
βββββββ¬ββββββ¬ββββββ¬ββββββ
β1 2 3β4 5 6β7 8 9β10 11β
βββββββ΄ββββββ΄ββββββ΄ββββββ
10 (your_function) 'Dyalog'
ββββββββ
βDyalogβ
ββββββββ
2 (your_function) 'The' 'cat' 'in' 'the' 'hat' 'sat' 'pat'
βββββββββββ¬βββββββββ¬ββββββββββ¬ββββββ
ββββββ¬βββββββββ¬ββββββββββ¬βββββββββββ
ββTheβcatβββinβtheβββhatβsatβββpatββ
ββββββ΄βββββββββ΄ββββββββββ΄βββββββββββ
βββββββββββ΄βββββββββ΄ββββββββββ΄ββββββ
5 (your_function) '' β result is 0-element vector of text vectors
4 (your_function) 5
βββ
β5β
βββ
your_function β
Solutions

