Last active
November 12, 2019 23:32
-
-
Save ZSalloum/7f62b8ceb759abfea171aa9bfdecdb3d to your computer and use it in GitHub Desktop.
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
MAX_ITER = 10000; | |
function getMax(arr){ | |
return arr[0]<=arr[1] ? 1 : 0; | |
} | |
function getMin(arr){ | |
return arr[0]<arr[1] ? 0 : 1; | |
} | |
const data = []; | |
data[0] = []; | |
data[1] = []; | |
data[0][0] = -2; | |
data[0][1] = 3; | |
data[1][0] = 3; | |
data[1][1] = -4; | |
console.log(data); | |
lower = 0; | |
upper = 0; | |
row = [0, 0]; | |
col = [0, 0]; | |
index = 0; | |
for(var i = 0; i < MAX_ITER; i++){ | |
col[0] += data[0][index]; | |
col[1] += data[1][index]; | |
//console.log("col", col); | |
index = getMax(col); | |
upper = col[index] / (i + 1); | |
row[0] += data[index][0]; | |
row[1] += data[index][1]; | |
index = getMin(row); | |
lower = row[index] / (i + 1); | |
//console.log("row", row); | |
} | |
console.log("lower", lower); | |
console.log("upper", upper); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment