Advertisement
AceScottie

list_sanner_basic.py

Apr 28th, 2019
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. import random, time
  2.  
  3. def main():
  4.     x = range(10000)
  5.     for i in range(5):
  6.         rem = random.randint(0, 9999)
  7.         if rem in x:
  8.             print("removing %s" %rem)
  9.             x.remove(rem)
  10.         else:
  11.             i+=1
  12.     i = 1
  13.     while True:
  14.         if i in x:
  15.             i += 1
  16.         else:
  17.             break
  18.     return i
  19.  
  20. if __name__ == "__main__":
  21.     times = []
  22.     for i in range(1000):
  23.         start = time.time()
  24.         lowest_missing = main()
  25.         end = time.time() - start
  26.         times.append(end)
  27.         print("Found the lowest missing value as %s in %ss" %(lowest_missing,end))
  28.     avarage = reduce(lambda x, y: x + y, times) / float(len(times))
  29.     print("avarage time: %s" %avarage)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement