My kid's baseball team has 13 kids. Each kid is supposed to rotate through the positions so that they all get equal time at each position. We have 4 outfielders, by the way, as these kids are only 7 years old.
I tried to write a little Javascript algorithm to rotate them through fairly. I came up with the following, but it doesn't seem to be as fair as I thought it would be, and it's confusing. I am sure there's an easier way. Suggestions?
var people = new Array("Amelie","Avery","Brennan","Clayton","Devin","Flynn","Haydn","Jack","Kai","Liam","Max","Maxi","Sterling");
    var people_copy = people.slice(0);
    var jobs = new Array("Pitcher","Catcher","Third Base","Short Stop","Second Base","First Base","Right Field","Ctr Right","Ctr Left","Left");
    var jobs_copy = jobs.slice(0);
    var result_set = new Array();
    for(i=0;i<jobs_copy.length;i++){
        j = i%jobs.length;
        result_set[j] = new Object();
          for(h=0;h<people_copy.length;h++){
                  if((jobs[0]) && (people[0])){
                    jobby = jobs[0].trim();
                    persony = people[0].trim();
                    result_set[j][jobby] = persony; 
                  }
                  var shifted = people.shift();
                  people.push(shifted);
                  var jobs_shifted = jobs.shift();
                  jobs.push(jobs_shifted);    
            }
            var shifted = people.shift();
            people.push(shifted);
          }
    for(i=0;i<result_set.length;i++){
        console.log("\nIteration: " + (i+1));
        for(h=0;h<jobs_copy.length;h++){
            l = jobs_copy[h];
            console.log(l + '=' + result_set[i][l]);
        }
    }
 
     
     
    