a, b = it.tee(iterable)
next(b, None)
return zip(a, b)
+
+
+def interesting_repetition(rep):
+ """Return True for indices [1,2,3,5,7,10,15,20,30,50,75,100,150,200,...]"""
+ if rep in (0, 1, 2, 3, 5, 7):
+ return True
+ elif rep < 10:
+ return False
+ elif rep in (10, 15, 20, 30, 50, 75):
+ return True
+ elif rep < 100:
+ return False
+ elif rep in (100, 150, 200, 300, 500, 750):
+ return True
+ elif rep < 1000:
+ return False
+ elif rep in (1000, 1500, 2000, 3000, 5000, 7500):
+ return True
+ elif rep < 10000:
+ return False
+ base = 100
+ while True:
+ base *= 10
+ if rep in (base * num for num in (10, 15, 20, 30, 50, 75)):
+ return True
+ elif rep < base*100:
+ return False
+
+ # could try to do this with math.log (e.g. number of digits is
+ # 1+math.floor(math.log(rep, 10))), but quickly get into problems with
+ # precision (e.g. log(1000, 10) = 2.9999999999996 should be 3)