Check if the integer in a list is not duplicated, and sequential
- by prosseek
testGroupList is a list of integer.
I need to check the numbers in testGroupList is sequential (i.e, 1-2-3-4...) and not duplicate numbers. Ignore the negative integer.
I implemented it as follows, and it's pretty ugly. Is there any clever way to do this?
buff = filter(lambda x: x 0, testGroupList)
maxval = max(buff)
for i in range(maxval):
id = i+1
val = buff.count(id)
if val == 1: print id,
elif val = 2: print "(Test Group %d duplicated %d times)" % (id, val),
elif val == 0: print "(Test Group %d missing)" % id,