Skip to main content
1 of 3
mleyfman
  • 5.2k
  • 1
  • 24
  • 48

I don't agree with your method of handling 0 or negative partition sizes.

A partition is always meant to be a sub-section of a whole. A partition with size 0 is impossible if the whole is non-empty, as there is no way to cut up a whole into sub-sections of size 0. The same logic applies for negative values. I would think raising a RuntimeException such as an IllegalArgumentException would make more sense in that context.

Now as for handling sub-section sizes larger than the size of your list, you already define that by having incomplete sub-sections if your sub-section size doesn't divide into your container size. You are missing a test for this, however.

mleyfman
  • 5.2k
  • 1
  • 24
  • 48