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?
> 10:is a hard-coded attempt then, the number10isn't relevant, only the split in continuity? What about[5,6],[5,7], this should be ignored too?arr1.append([x,y])to be consistent with your original list10is a hard-coded attempt, if there is a better way please let me know ;) The array size may change, but there will always be one lagre "jump" in thexvalue somewhere, and this is where I want to split the array.