Selecting random items from list and rotating them

Hi everyone. I just got started with Grasshopper, so I’m very much new at this, but loving it already.

I’m trying to recreate this model in Grasshopper, in an algorithmic way.

I’ve managed to recreate one of the boxes (kind of). Now I’m trying to set up the pattern, but I would like it to be random. I’m having trouble coming up with the actual algorithm, though.

I’m able to generate a list of items, randomly select some of them, and rotate them. I can also select the item after a rotated one and move it to the right.

However, I’m having trouble selecting all of the items after an item that’s been rotated, and moving all of them.

Let’s say I have a list of 15 elements and numbers 3, 6, and 7 are rotated. I would need to move numbers 4 through 14 (since it starts at 0) to the right by an x amount; numbers 7 through 14 to the right by a 2x amount; and numbers 8 through 14 by a 3x amount.

How should I go about doing this?

I should note that maybe it’s better not to do it randomly, but set up a number slider for the amount of elements to rotate and some sliders, a list, or some kind of pattern to select which ones to rotate. Especially if that’s easier.

I’ll add my current non-working setup: rhino file and grasshopper file. I should note that since I’m new, it probably looks horribly disorganized. Sorry about that.