Algorithm to get group index of item in chunked array -
so have arbitrary array of items: array = [0,1,2,3,4]; and when it's been chunked looks like: array.chunk(2) => [[0,1],[2,3],[4]]; array.chunk(3) => [[0,1,2],[3,4]]; what i'd algorithm index of group index in, based on group size. for instance, running algorithm on each element in array yield: array.chunkindex( chunksize = 2, index = n ) 0 => 0 1 => 0 2 => 1 3 => 1 4 => 2 array.chunkindex( chunksize = 3, index = n ) 0 => 0 1 => 0 2 => 0 3 => 1 4 => 1 so running algorithm on index chunksize = 1 yield original index. how go doing this? clear, don't want chunk array, determine group in, without looping , without built-in functions, if possible. also in psuedo-code: chunkindex = index / chunksize it's simple integer division means case have careful of languages return float/decimal/real. cases, need floor function find integer part of result. may wish handle negative values also.