def get_number(x, r):
l = []
for i in range(len(x)):
if i+1<len(x):
if x[0]+r>=x[i] and x[0]+r<x[i+1]:
print "----",x[i]
l.append(x[i])
break
def look_forward(i,x,l):
for j in range(i,len(x)):
if x[i]+r<x[j]:
print '----',x[j]
l.append(x[j])
return look_forward(j,x,l)
look_forward(i,x,l)
print l
if name == "main":
get_number([1,2,4,5,8,12], 3)
网友评论