代码拉取完成,页面将自动刷新
/**
matrix
0 1 2 3 4 5 6 7
0 0 0 1 5 0 4 5 5
1 2 2 3 7 2 6 7 7
2 2 2 3 7 2 6 7 7
3 0 0 1 5 0 4 5 5
4 2 2 3 7 2 6 7 7
5 0 0 1 5 0 4 5 5
6 0 0 1 5 0 4 5 5
7 2 2 3 7 2 6 7 7
Optimization:
0 1 4 3 6 7 2 5
0 0 0 0 5 5 5 1 4
5 0 0 0 5 5 5 1 4
3 0 0 0 5 5 5 1 4
6 0 0 0 5 5 5 1 4
1 2 2 2 7 7 7 3 6
2 2 2 2 7 7 7 3 6
4 2 2 2 7 7 7 3 6
7 2 2 2 7 7 7 3 6
Because:
1,4 3,6
1 0 1 0
0 0 1 1
0 1 0 1
Use:
4 => 1,
6 => 3,
7 => 4,
Compress:
0 1 3 4 2 5
0 0 0 5 5 1 1
3 0 0 5 5 1 1
5 0 0 5 5 1 1
1 2 2 4 4 3 3
2 2 2 4 4 3 3
4 2 2 4 4 3 3
Swap:
1 <=> 3,
2 <=> 5,
Order:
0 3 1 4 2 5
0 0 0 2 2 3 3
1 0 0 2 2 3 3
2 0 0 2 2 3 3
3 5 5 4 4 1 1
4 5 5 4 4 1 1
5 5 5 4 4 1 1
*/
const matrix = [
[0, 0, 1, 5, 0, 4, 5, 5],
[2, 2, 3, 7, 2, 6, 7, 7],
[2, 2, 3, 7, 2, 6, 7, 7],
[0, 0, 1, 5, 0, 4, 5, 5],
[2, 2, 3, 7, 2, 6, 7, 7],
[0, 0, 1, 5, 0, 4, 5, 5],
[0, 0, 1, 5, 0, 4, 5, 5],
[2, 2, 3, 7, 2, 6, 7, 7],
];
Object.defineProperty(matrix, "debug", {
get: function () {
let str = "\n 0 1 2 3 4 5 6 7\n";
for (let i = 0; i < this.length; i++) {
str += `${i} ${this[i].join(" ")}\n`;
}
return str;
},
});
/**
* => A,B <=
* I. matrix[X][A] === matrix[X][B]
* II. matrix[A][X] === matrix[B][X]
*/
for (let A = 0; A < 8; A++) {
for (let B = A + 1; B < 8; B++) {
OUTER: {
for (let i = 0; i < 8; i++) {
if (matrix[i][A] !== matrix[i][B]) break OUTER;
if (matrix[A][i] !== matrix[B][i]) break OUTER;
}
console.log(`Match A: ${A},B: ${B}`);
}
}}
/**
* Know that Pairs are [1,4] and [3,6]
* Now make the matrix more like Older Version.
*/
const compressed = `
0 1 3 4 2 5
0 0 0 5 5 1 1
3 0 0 5 5 1 1
5 0 0 5 5 1 1
1 2 2 4 4 3 3
2 2 2 4 4 3 3
4 2 2 4 4 3 3
`
const compressArray = Array.from(compressed);
for (let i = 0; i < compressArray.length; i++) {
if(compressArray[i] === '1') compressArray[i] = '3';
else if(compressArray[i] === '3') compressArray[i] = '1';
else if(compressArray[i] === '2') compressArray[i] = '5';
else if(compressArray[i] === '5') compressArray[i] = '2';
}
console.log("Is Old Version ? \n",compressArray.join(""));
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。