I have some numbers and want to make some pairs out of them. This is my data:
points=np.arange(0,10)
And this array defines how to make the pairs:
repetition= np.array([1, 1, 2, 3, 3])
Then, I want to create such pairs:
[(0, 1), (1, 2), (2, 4), (3, 5), (4, 7), (5, 8), (6, 9)]
I have tried the following code but it is not giving me what I want:
L=[]
k=0
for r in repetition:
last= k+r
L.append(points[k:last])
k= last
lmax= len(max(L,key=len))
L=[ np.concatenate((np.full(lmax-len(l),None),l)) for l in L ]
L= [[e for e in l if e] for l in zip(*L)]
result= sorted([p for l in L for p in zip(l,l[1:])])
I have also uploaded a fig to clarify my request more. red lines are connecting the pairs. I reality, my data are much more complex but they follow the same role. The repetition defines that each value of points should be connected to which one. In advance, I do appreciate any help. Thanks for devoting time.

repetition. Firtst value inrepetitionis1, so the first variable should be paired with next one. For the second,repetitionis1, so it should be connected with next one. For the third variable ofpoints, in therepetitionwe reach2: it means variables numbered 3 and 4 ofpointsshould be connected to their next two variable (2 with 4 and 3 with 5). For the fifth variable ofpointsthe number inrepetitionis 3 which means variables named 4,5 and 6 should be paired with 7, 8, 9, respectively.