Attempt to simplify data input

What I want is to easily configure the following input so the pins are enabled and disabled for the given time and repetitions. So for example this would enable pins 18, 19 and 20 for 2 seconds then disable them and enable 17 and 19 for 1 second. This would happen 10 times and the the next repetition would start... 3 times pin 16 and 18 for 1 second... etc.

Input data

repetitions | duration  | pins
 10         |           | 
            |   2000    | 20,18,19
            |   1000    | 17,19
  3         |           |
            |   1000    | 16,18

....and a lot more.

I thought to create classes and so I would be able to set the data and handle the funcionality easily.

Pseudo code

class LedzItem{
    array int[];
    int duration;
    logics(){...}
    void add(){}
}    
class LedzGroup{
    array LedzItem[];
    int repetitions;
    logics(){...}
    LedzItem add(){}
}
class Ledz{
    array LedzGroup[];
    logics(){...}
    LedzGroup add(){}
}
void setup(){
    Ledz ledz = Ledz();
    LedzGroup ledzGroup = ledz.Add(10);
    LedzItem ledzItem = ledzGroup.add(2000);
    ledzItem.add(20);
    ledzItem.add(18);
}

I have working code (Ledz.ino on github) but it takes way to much memory because of the predefined array sizes.

To fix the array problem I tried working with a dynamic array like in this answer but then my program crashes when I add two groups. And when I add only one group I get some wrong values, so I guess pointer errors?(ledz_dynamic attempt on github)

So basically my question is: Is this a good way to process the input and accomplish what I want?

I don't want to write the input completely in for loops etc. I thought to make it easier to create classes which handle the for loops. That way I could more easily could insert the input data.

Have a look at this code that was designed to turn on LEDs in patterns. Very similar application, and you just need to edit the data table for different patterns.

Thanks for the link, it does looks like the same idea. But I find the cofiguration of the blinking leds, loops and duration pretty confusing.

bvdven:

repetitions | duration  | pins

10         |           |
           |   2000    | 20,18,19
           |   1000    | 17,19
 3         |           |
           |   1000    | 16,18

…and a lot more.

So in the first cycle 19 stays on for the whole 30 seconds (10*(2+1))?
And in the second cycle 16 and 18 stay on for the whole 3 seconds (3 * 1)?

@Johnwasser In this example yes it would, but in the 'real' input their would be more variety in the pins and number of rows in a repetition.

I think I've got it now, a working version with dynamic urls. Now I can configure the data like this:

lg = ledz.add(1); //repetitions
    li = lg->add(2000); // duration
      li->addPin(14);
      li->addPin(15);
      li->addPin(16);
      li->addPin(17);

    li = lg->add(2000);
        li->addPin(18); //pin
        li->addPin(19); //pin

    // Group 2
   lg = ledz.add(2);
    li = lg->add(3000);
    li->addPin(14);

Whole code visible on github