气泡解决方案数据处理与优化
1. 初始气泡得分计算
首先,我们有一组气泡解决方案的得分数据,代码如下:
var scores = [60, 50, 60, 58, 54, 54,
58, 50, 52, 54, 48, 69,
34, 55, 51, 52, 44, 51,
69, 64, 66, 55, 52, 61,
46, 31, 57, 52, 44, 18,
41, 53, 55, 61, 51, 44];
var highScore = 0;
var output;
for (var i = 0; i < scores.length; i++) {
output = "Bubble solution #" + i + " score: " + scores[i];
console.log(output);
if (scores[i] > highScore) {
highScore = scores[i];
}
}
console.log("Bubbles tests: " + scores.length);
console.log("Highest bubble score: " + highScore);
var bestSolutions = [];
for (var i = 0; i < scores.length; i++) {
if (scores[i] == highScore) {
超级会员免费看
订阅专栏 解锁全文

2043

被折叠的 条评论
为什么被折叠?



