# For demonstration, the original data have been simplified as follows.
# In reality, you can pre-process the data by using the trick on line 29 of your code
list_IN_0 = [
(1,0),(1,3),(1,4),(1,7),(1,8),(1,12),(1,13),(1,16),(1,17),(1,22),(1,23),
(2,0),(2,3),(2,4),(2,7),(2,8),(2,12),(2,13),(2,16),(2,17),(2,22),(2,23),
(3,0),(3,3),(3,4),(3,7),(3,8),(3,12),(3,13),(3,16),(3,17),(3,22),(3,23)
]
# according L21 the logic of if-statement, I suppose: IN(1)=5, IN(2)=10, IN(3)=15, IN(4)=20
# distance = iterate_y - first_y
# we only took (5 < distance < 10) OR (15 < distance < 20)
# So, the result will be => [[(1,7), (1,8), (1,16), (1,17)],
# [(2,7), (2,8), (2,16), (2,17)],
# [(3,7), (3,8), (3,16), (3,17)]]
# MAIN LOGIC OF THE FUNCTION
# Using "List comprehension" technique
unique_x_values = sorted(set([x_val[0] for x_val in list_IN_0]))
group_list = [
sorted([point for point in list_IN_0 if point[0] == value])
for value in unique_x_values
]
OUT = [
[tracker for tracker in sublist
if tracker[1] - sublist[0][1] == 0
or 5 < tracker[1] - sublist[0][1] < 10
or 15 < tracker[1] - sublist[0][1] < 20
]
for sublist in group_list
]
# Print processing value, you can ignore these lines in Dynamo
print(f'{unique_x_values = }')
print(f'{group_list = }')
print(f'{OUT = }')