# How to copy list with selected number of consecutive numbers and not others

How does one copy a list or table containing lots of sequences of numbers into another sheet without allowing any consecutive numbers to be copied. ie Lists comtaining sequences that have no consecutive numbers to be copied eg 3 2 7 3 0 would not be copied as it has 2 3 , 3 7 3 6 8 5 would not be copied as it contains consecutive numbers ( 5 and 6, 5 6 7, 6 7 8 etc)

It would be useful to allow list containing eg 2 consecutive numbers or less to be copied and not allow sequence in list containg 3 consecutive or more numbers.so for this 3 2 7 3 0 and al others would be allowed to be copied but 3 7 3 6 8 5 would not as it contains 3 or more consecutives.

If you know the programming language python, then you can sort each sequence, and check the number of consecutive numbers it contains. If it is greater than 2, then you can return the sequence in its original order, else you return nothing.

If you attach a reduced sample file, explaining/marking what should be copied and what not. Could help to help.

Thanks.

To clearify.

List example
3,7,44,60,12,45,3,22,41 0
6,56,28,71,88,33,72,57 3
97,20,15,37,22,21,67,7 1
2,5,11,74,92,52,12,3,75 3
7,19,26,18,15.88,29,82 0

I want to put a formula in sheet 2 cell A7
which returns (copies) the list above but does not return any sequences which has quantity of 3 or more consequtive numbers.

the formula would return following list
3,7,44,60,12,45,3,22,41 (as it contains no consequtive numbers)

97,20,15,37,22,21,67,7 (as it contains only 1 consequtive number)

7,19,26,18,15.88,29,82 (as it contains no consequtive numbers)

it would not retuen other 2 sequence as they contain 3 consequtive numbers

Would you know how to write the formula or know another way to do it.

Thanks.
but I don’t know any Pythons around here,
anyway, i’m afraid of snakes.
Can libra do this identifying how many consecutive numbers each sequence in the list have ?
like =countif(A1:A6,”n1.n2;else”") but this or similar would count numbers or attributes not how many consecutive numbers there are. what would formula look like to do this.

To clearify.

List example
3,7,44,60,12,45,3,22,41 0
6,56,28,71,88,33,72,57 3
97,20,15,37,22,21,67,7 1
2,5,11,74,92,52,12,3,75 3
7,19,26,18,15.88,29,82 0

I want to put a formula in sheet 2 cell A7
which returns (copies) the list above but does not return any sequences which has quantity of 3 or more consecutive numbers.

the formula would return following list
3,7,44,60,12,45,3,22,41 (as it contains no consecutive numbers)

97,20,15,37,22,21,67,7 (as it contains only 1 consecutive number)

7,19,26,18,15.88,29,82 (as it contains no consecutive numbers)

it would not retuen other 2 sequence as they contain 3 consecutive numbers

Would you know how to write the formula or know another way to do it.

However I twist it, but still only find one line (the third with 20,21,22) with three consecutive numbers??

``````rows = [[3,7,44,60,12,45,3,22,41],
[6,56,28,71,88,33,72,57],
[97,20,15,37,22,21,67,7],
[2,5,11,74,92,52,12,3,75],
[7,19,26,18,15,88,29,82]]

#rows = [sorted(set(row)) for row in rows]

def check_triples( sequence ):
sequence = set(sequence)
for number in sequence:
if sequence.issuperset((number,number+1,number+2)):
return True
return False

def main(*_):
for row in rows:
if not check_triples(row):
print(row)
main()
``````

________prints :

``````[3, 7, 44, 60, 12, 45, 3, 22, 41]
[6, 56, 28, 71, 88, 33, 72, 57]
[2, 5, 11, 74, 92, 52, 12, 3, 75]
[7, 19, 26, 18, 15, 88, 29, 82]
``````