Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import bisect
- import random
- """ Use a constant seed to ensure that the
- same pseudo-random numbers are used each
- time the loop is run. """
- random.seed(1)
- print 'New pos Contents'
- print '--- --- --------'
- # Generate random numbers and
- # insert them into a list in
- # sorted order.
- l = []
- for i in range(1, 15):
- r = random.randint(1, 100)
- position = bisect.bisect(l, r)
- bisect.insort(l, r)
- print '%3d %3d' % (r, position), l
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement