xxxxxxxxxx
92
var scores=[];
var rates=[6,6.5,7,7.5,8,8.5,9,9.5,10];
var final=[];
function setup() {
createCanvas(400, 400);
for(var i=0; i<rates.length-2; i++)
{
perms(rates[i], rates[i+1], rates[i+2]);
}
sortScores();
deleteDups();
console.table(final);
}
function draw() {
background(220);
}
function perms(a,b,c)
{
scores.push(new ScoreSet(a,a,a));
scores.push(new ScoreSet(a,a,b));
scores.push(new ScoreSet(a,a,c));
scores.push(new ScoreSet(a,b,b));
scores.push(new ScoreSet(a,b,c));
scores.push(new ScoreSet(a,c,c));
scores.push(new ScoreSet(b,b,b));
scores.push(new ScoreSet(b,b,c));
scores.push(new ScoreSet(b,c,c));
scores.push(new ScoreSet(c,c,c));
//console.table(scores);
}
function sortScores()
{
var temp;
for(var i=0; i<scores.length-1; i++)
{
for(var j=0; j<scores.length-1; j++)
{
if(scores[j].score>scores[j+1].score)
{
temp=scores[j];
scores[j]=scores[j+1];
scores[j+1]=temp;
}
//console.table(scores);
}
}
}
function deleteDups()
{
var nodupes;
for(var i=0; i<scores.length; i++)
{
nodupes=true;
for(var j=i+1; j<scores.length && nodupes===true; j++)
{
if((scores[i].a==scores[j].a) && (scores[i].b==scores[j].b) && (scores[i].c==scores[j].c))
{
nodupes=false;
}
}
if(nodupes)
{
final.push(scores[i]);
}
}
}