So you have 7 different Y values, you can make a bool array with 7 items. Each time you use a Y coord, you mark the bool array index as used.
You can modify the nearest function to do this, in fact.
You will need to deal with the fact that no space are left, also