Created
August 7, 2013 06:53
-
-
Save hydra1983/6171794 to your computer and use it in GitHub Desktop.
An algorithm to generate progress info for tasks. Run with nodejs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var num = 0; | |
var num2 = 0.0; | |
var num3 = 0.0; | |
var num4 = 0.0; | |
var num5 = 0.0; | |
console.log("part1"); | |
var part1 = [{ | |
batchCount : 5 | |
},{ | |
batchCount : 3 | |
},{ | |
batchCount : 0 | |
},{ | |
batchCount : 1 | |
}]; | |
var n = part1.length; | |
for(var i = 0;i < n;i++){ | |
num = 0; | |
num5 = 0.0; | |
num2 = 15.0 + ((40.0 / n)*i); | |
num3 = 15.0 + ((40.0 / n)*(i + 1.0)); | |
num4 = num3 - num2; | |
do { | |
console.log("avg : " + num4 + " batch : " + num + " percent : " + parseInt(num2 + num5) + " all batch : " + part1[i].batchCount); | |
num++; | |
if(part1[i].batchCount > 0){ | |
num5 = (1.0 * num) / (1.0 * part1[i].batchCount) * num4; | |
} else { | |
num5 = num4 * 0.9; | |
} | |
}while(part1[i].batchCount > 0 && num < part1[i].batchCount); | |
console.log("avg : " + num4 + " batch : " + num + " percent : " + parseInt(num2 + num5) + " all batch : " + part1[i].batchCount); | |
console.log(); | |
} | |
console.log("part2"); | |
var part2 = [{ | |
batchCount : 2 | |
},{ | |
batchCount : 4 | |
},{ | |
batchCount : 5 | |
},{ | |
batchCount : 1 | |
},{ | |
batchCount : 10 | |
}]; | |
n = part2.length; | |
for(i = 0;i < n;i++){ | |
num = 0; | |
num5 = 0.0; | |
num2 = 55.0 + ((40.0 / n)*i); | |
num3 = 55.0 + ((40.0 / n)*(i + 1.0)); | |
num4 = num3 - num2; | |
do { | |
console.log("avg : " + num4 + " batch : " + num + " percent : " + parseInt(num2 + num5) + " all batch : " + part2[i].batchCount); | |
num++; | |
if(part2[i].batchCount > 0){ | |
num5 = (1.0 * num) / (1.0 * part2[i].batchCount) * num4; | |
} else { | |
num5 = num4 * 0.9; | |
} | |
}while(part2[i].batchCount > 0 && num < part2[i].batchCount); | |
console.log("avg : " + num4 + " batch : " + num + " percent : " + parseInt(num2 + num5) + " all batch : " + part2[i].batchCount); | |
console.log(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment