I have an array of possible positions and another array of filled positions, which is a subarray of possiblePositionsArray . possiblePositionsArray fixed in number and already defined. I would like to find the farthest 3 consecutive points to the right and left of the selected element x of the element of the element in filledPositions . Let me explain this example further. Let's say
possiblePositionsArray = [p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15] filledPositions = [p1, p2, p4, p7, p8, p9, p10, p12, p13, p14, p15]
Both are CGPoint arrays, and they all have the same y positions and are arranged in ascending order. If I choose p11.x , then there will be the following three consecutive points on the right and left.
[p7, p8, p9] and [p8, p9, p10] To the Left of p11 [p12, p13, p14] and [p13, p14, p15] to the right of p11
But the farthest left and right will be:
farthest to left of p11 is [p7, p8, p9] farthest to right of p11 is [p13, p14, p15]
How can i achieve this?