testGroupList is a list of integer. I need to check the numbers in testGroupList is sequential and not duplicate numbers. Ignore the negative integer.
For example, [1,2,-1,2,3,4] is an error as 2 is duplicated, but [-1,3,2,4,1,5] is OK.
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,