def IsContinuous(seq, num = 5): zeros = 0; d = 0 seq = sorted(seq) for i in range(num - 1): if seq[i] == 0: zeros += 1 continue if seq[i] == seq[i + 1]: return False d += seq[i + 1] - seq[i] - 1 return zeros >= d
时间: 2024-10-26 23:26:38
def IsContinuous(seq, num = 5): zeros = 0; d = 0 seq = sorted(seq) for i in range(num - 1): if seq[i] == 0: zeros += 1 continue if seq[i] == seq[i + 1]: return False d += seq[i + 1] - seq[i] - 1 return zeros >= d