Hi, trying to reduce the numbers in a list By Roundup with a Range of 30.
Like this ?
Hi, Thank you for the fast reply, but is has to do with min. and max. number in the list.
So for your example, the difference form min. and max. number in the list must be smaller than 30.
0 to 15 = smaller than 30
15 to 22 = smaller than 30 | 0 to 22 = smaller than 30
22 to 31 = smaller than 30 | 0 to 31 = bigger than 30 ## So 0, 15, 22 is a group[1]
31 to 66 = bigger than 30 ## So 31 is a new group[2]
66 to 78 = smaller than 30
78 to 95 = smaller than 30 | 66 to 95 = smaller than 30
95 to 103 = smaller than 30 | 66 to 103 = bigger than 30 ## So 66, 78, 95 is a group[3]
Last is 103 | ## group[4]
I see. Like this then ? Note : you might want to sort the input before using the Python Script.
Python Script :
input = IN[0]
rng = IN[1]
result = []
visited = []
for i in range(len(input)):
if(input[i] in visited):
continue;
sub_result = [input[i]];
for j in range(i+1,len(input)):
if(abs(input[j]-input[i]) <= rng):
visited.append(input[j]);
sub_result.append(input[j]);
result.append(sub_result);
OUT = result;
1 Like