Attaching panels created on rhino randomly within rules explained in the attached rhino file

Hello,

I’ve created 6 different panels on Rhino with a zigzag bottom line.
G00046201.gh (22.6 KB)

step1: I want to attach them randomly in a way that the bottom line of the whole strip doesn’t exceed the middle line of the strip. (Please refer to the attached rhino file as I explained things with drawings).
Mahdiyar (a member on this forum) helped with a script that attached the panels randomly, but it didn’t give the result I want as the bottom line of the strip should not exceed the red lines I showed in the rhino file. (Please see the script)

Step 2: after creating the strip that is based on the random attaching of the different panels created on rhino, I want to loop them to reach a specific height and with every loop I want to increase the width of the panel by a number (as I explained in the rhino file)

The script is using C# coding, but I’m more familiar with python, so would be great if it is based on python…

I would appreciate any help regarding any step

Please advise, and thanks in advance

190215_attaching panels created on rhino.3dm (2.0 MB)

Rhino File with explanation