I want to test if a list contains consecutive integers and no repetition of numbers. For example, if I have
l = [1, 3, 5, 2, 4, 6]
It should re
import numpy as np
import pandas as pd
(sum(np.diff(sorted(l)) == 1) >= n) & (all(pd.Series(l).value_counts() == 1))
We test both conditions, first by finding the iterative difference of the sorted list np.diff(sorted(l))
we can test if there are n
consecutive integers. Lastly, we test if the value_counts()
are all 1, indicating no repeats.