Comment by Benjamin_Dobell

1 year ago

If it is dynamic one of the loops will also suffer from an off-by-one issue. You can't add 1-based indices together like you can zero-based indices.

It's also worth noting your solution exhibits similar off-by-one behaviour. The left hand side constants (integer values) do not match the right. It's error prone.

  >You can't add 1-based indices together like you can zero-based indices.

I think you are right but I am unable to articulate why. But I think 0 based indexes are able to fruitfully capture "going nowhere" iteratively than 1 based indexes, which do require a decrement in that circumstance.

sorry, where is the off by one? the code offered is of course only a solution for the fixed-size groups