I have an array of coordinates like this:
array = [[1,6],[2,6],[3,8],[4,10],[5,6],[5,7],[18,6],[19,5],[17,9],[10,5]]
I want to split the array between 6
. and 7
. coordinate ([5,7],[18,6])
because there is a gap in the X
value there. I want to get two separate arrays, arr1
and arr2
, where arr1
is the values before the split and arr2
is the values after.
I want to say that if the next X
value is larger than a difference of 10
, it will append to arr2
, else arr1
, something like this:
arr1 = []
arr2 = []
for [x,y] in array:
if next(x) > 10:
arr2.append(x,y)
else:
arr1.append(x,y)
Can someone please help me with this problem?