Skip to main content
edited tags
Link
chunes
  • 26.8k
  • 3
  • 24
  • 53
Tweeted twitter.com/StackCodeGolf/status/1023855754770632704
Post Reopened by fəˈnɛtɪk, Giuseppe, Οurous, Chas Brown, Jo King
edited tags
Link
Jo King
  • 47.5k
  • 5
  • 125
  • 186
Add last chunk explanation
Source Link
Tom Viner
  • 443
  • 2
  • 8
  1. Your program must take
    • a list of items
    • a positive integer chunk size
    • a predicate function (takes an item, and returns true or false)
  2. You must return the input list split into chunks
  3. Each chunk is a list of items
  4. Overall the items must remain in the same order, with none disgarded
  5. The number of items passing predicate in each chunk (except possibly the last) should match the input chunk size.
  6. items failing the predicate should not count toward this size
  7. Items failing the predicate are
    1. still included in the output chunks
    2. 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
  8. The final chunk may be of size less than the chunk size because all the items have been accounted for.
  1. Your program must take
    • a list of items
    • a positive integer chunk size
    • a predicate function (takes an item, and returns true or false)
  2. You must return the input list split into chunks
  3. Each chunk is a list of items
  4. Overall the items must remain in the same order, with none disgarded
  5. The number of items passing predicate in each chunk (except possibly the last) should match the input chunk size.
  6. items failing the predicate should not count toward this size
  7. Items failing the predicate are
    1. still included in the output chunks
    2. 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
  8. The final chunk may be of size less than the chunk size
  1. Your program must take
    • a list of items
    • a positive integer chunk size
    • a predicate function (takes an item, and returns true or false)
  2. You must return the input list split into chunks
  3. Each chunk is a list of items
  4. Overall the items must remain in the same order, with none disgarded
  5. The number of items passing predicate in each chunk (except possibly the last) should match the input chunk size.
  6. items failing the predicate should not count toward this size
  7. Items failing the predicate are
    1. still included in the output chunks
    2. 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
  8. The final chunk may be of size less than the chunk size because all the items have been accounted for.
Allow empty chunk or no chunk, when input is empty
Source Link
Tom Viner
  • 443
  • 2
  • 8
Loading
Tag with code-golf
Link
Tom Viner
  • 443
  • 2
  • 8
Loading
Post Closed as "Not suitable for this site" by Laikoni, Erik the Outgolfer, xnor, Jonathan Allan, Luis felipe De jesus Munoz
Source Link
Tom Viner
  • 443
  • 2
  • 8
Loading