Advertisement
z-nexx

Sort HSL in python

Sep 8th, 2013
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. from random import randrange
  2. import sys
  3. c=[]
  4. r=[[]]
  5. l=0
  6. elems=5
  7. for x in range(elems):
  8.         c=c+[[randrange(360),randrange(100),randrange(100)]]
  9. c=sorted(c,key=lambda l: l[0])
  10. for x in range(elems-1):
  11.         r[l]=r[l]+[c[x]]
  12.         if (c[x+1][0]-c[x][0])>=30:
  13.                 l+=1
  14.                 r=r+[[]]
  15. r[l]=r[l]+[c[x+1]]
  16. if 360-r[-1][-1][0]+r[0][0][0]<30:
  17.         r[0].insert(0,r[-1])
  18.         r.pop()
  19. print r
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement