- Your program must take
- a list of items
- a positive integer chunk size
- a predicate function (takes an item, and returns true or false)
- You must return the input list split into chunks
- Each chunk is a list of items
- Overall the items must remain in the same order, with none disgarded
- The number of items passing predicate in each chunk (except possibly the last) should match the input chunk size.
- items failing the predicate should not count toward this size
- Items failing the predicate are
- still included in the output chunks
- allocated to the earliest chunk, in the case that a chunk is "full" but the next items are ones failing the predicate
- thus the final chunk may not consist solely of items failing the predicate
- The final chunk may be of size less than the chunk size because all the items have been accounted for.
Post Closed as "Not suitable for this site" by Laikoni, Erik the Outgolfer, xnor, Jonathan Allan, Luis felipe De jesus Munoz