mylist = [10, 11, 12, 801, 802, 803,820, 2000, 2010, 2020]
I want it to be split into 3 sublists based on variations in values:
output should be:
sublist_1 = [10,11,12]
sublist_2 = [801,802,803,820]
sublist_3 = [2000,2010,2020]
The numerical distance between any two of sublists should be >30, e.g. the distance between sublist_1 and sublist_2 is 800-12 = 788. But the distance with any two neighbors in a sublist should be <20, e.g. in sublist_2, the maximum distance with any two neighours is 820-803 = 17.