Created
September 4, 2013 05:42
-
-
Save supercavitation/6433123 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy.random as random | |
from time import clock | |
def r_step_generator(lo, hi): | |
num = lo | |
diff = hi - lo | |
while True: | |
num += random.randint(0, diff) | |
if num < hi: | |
yield num | |
else: | |
raise StopIteration | |
N=100000000 | |
t1=clock() | |
u=range(0,N) | |
x=random.randint(0,N,N/100) | |
y=0 | |
for i in r_step_generator(0,N): | |
if i>len(u): | |
break | |
u.insert(x[y],i) | |
y+=1 | |
t2=clock() | |
print t2-t1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment