I hoping someone can help me with a problem I’m stuck(again) with.
if i have coordinates:
x = array[0,1,2,3,4,3,2,3,-2,-4,-7,2,2]
y = array[0,1,2,3,4,5,6,7,8,9,10,11,12]
and with help in Categorizing the list of array in python, i could make:
x = [(0, 1, 2, 3, 4), (4, 3, 2), (2, 3), (3, -2, -4, -7), (-7, 2), (2, 2)]
The question is, how should i made y like this:
y = [(0,1,2,3,4),(4,5,6),(6,7),(7,8,9,10),(10,11),(11,12)]
since, x and y is actually coordinates and they bounded each other.
i have tried to use loop function, and i realize the code is still wrong
se = []
for i in range(len(z)):
k = z[i]
for i in range(len(k)):
se.append(y[i])
best regards,
Glenn
The following does what you want:
Result:
This basically constructs a list of positions where
ywill be split. We figure this out using the length of each tuple inx, but it gets a little tricky because the last element of a set is included as the next element in the following set.Here is one of the intermediate values which may help to clarify how this works:
We use this to construct the new
ylike this: