deviding an array into somewhat equal parts?

Hello,

I am looking for a simpler way to divide an array into 12 equal parts... (or somewhat equal)

i did this:

CRGB temp[patternLength];

  if (justonce == 0) {
    justonce = 1;
    fill_gradient(temp, 0, CHSV(20, 255, 240) , patternLength / 6, CHSV(20, 255, 240));
    fill_gradient(temp, patternLength / 6, CHSV(20, 255, 240) , ((patternLength / 6) + (patternLength / 12)), CHSV(20, 80, 200));
    fill_gradient(temp, ((patternLength / 6) + (patternLength / 12)), CHSV(20, 80, 200) , patternLength / 3, CHSV(160, 255, 255));
    fill_gradient(temp, (patternLength / 3), CHSV(160, 255, 255) , (2 * patternLength / 3), CHSV(160, 255, 255));
    fill_gradient(temp, (2 * patternLength / 3), CHSV(160, 255, 255) , ((2 * patternLength / 3) + (patternLength / 12)), CHSV(160, 80, 200));
    fill_gradient(temp, ((2 * patternLength / 3) + (patternLength / 12)), CHSV(160, 80, 200) , (5 * patternLength / 6), CHSV(20, 255, 240));
    fill_gradient(temp, (5 * patternLength / 6), CHSV(20, 255, 240) , patternLength, CHSV(20, 255, 240));
  }

but, its very sloppy.. and it doesn't seem to work well.

basically, it divides the array into 12ths, and fills in a color... is there an easier way to do this? I thought of the modulus operator, but i'm not sure how it would work here.

Is your array length divisible by 12 without remainder? Cause then its pretty easy to address arrays elements using pointers:

* ( yourArray + ( segmentLength * segmentIndex ) + indexInSegment )

// PS: segmentLength is 1/12 of yourArray length
// so indexInSegment should be between 0 and segmentLength-1
// and segmentIndex is between 0 and 11

I could make it evenly divisible, but I don't understand your code

basically,

fill_gradient(temp, 0, CHSV(20, 255, 240) , patternLength / 12, CHSV(20, 255, 240));

temp is the array, 0 is where the segment of the array starts, chsv is the start color, patternLength /12 is the end of the segment, and finally the end color

how would I use a pointer there?

I guess your function does all the work for you then.

Sorry, I don't understand what you mean by 'divide an array into 12 equal parts', can you explain better?