Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- c=[];
- r=[[]];
- l=0;
- elems=5;
- for(x=0;x<elems;x++){
- c.push([Math.floor(Math.random()*360),Math.floor(Math.random()*100),Math.floor(Math.random()*100)]);
- }
- c=c.sort(function(a,b){
- if(a[0] == b[0])return 0;
- return(a[0]>b[0])?1:-1;
- });
- for(x=0;x<elems-1;x++){
- r[l].push(c[x]);
- if(c[x+1][0]-c[x][0]>=30){
- l++;
- r.push([]);
- }
- }
- r[l].push(c[x]);
- if (360-r.slice(-1)[0].slice(-1)[0][0]+r[0][0][0]<30){
- for(x=r.slice(-1)[0].length-1;x>=0;x--){
- r[0].splice(0,0,r.slice(-1)[0][x]);
- }
- r.pop();
- }
- console.log(r);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement