1 Star 0 Fork 0

jimgo/Three Plus One Game

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
findBye.js 1.88 KB
一键复制 编辑 原始数据 按行查看 历史
jimgo 提交于 2024-04-04 20:56 . just commit
const A = [
[0, 1], [0, 2], [0, 3], [1, 0], [1, 2], [1, 3],
[2, 0], [2, 1], [2, 3], [3, 0], [3, 1], [3, 2],
];
const B = [
[0, 1, 2], [0, 1, 3], [0, 2, 1], [0, 2, 3], [0, 3, 1], [0, 3, 2],
[1, 0, 2], [1, 0, 3], [1, 2, 0], [1, 2, 3], [1, 3, 0], [1, 3, 2],
[2, 0, 1], [2, 0, 3], [2, 1, 0], [2, 1, 3], [2, 3, 0], [2, 3, 1],
[3, 0, 1], [3, 0, 2], [3, 1, 0], [3, 1, 2], [3, 2, 0], [3, 2, 1],
];
const FS = [
(p, n) => p & n,
(p, n) => ~p & n,
(p, n) => p & ~n,
(p, n) => ~p & ~n,
(p, n) => p | n,
(p, n) => ~p | n,
(p, n) => p | ~n,
(p, n) => ~p | ~n,
(p, n) => p ^ n,
(p, n) => ~p ^ n,
(p, n) => p ^ ~n,
(p, n) => ~p ^ ~n,
]
let x, y, z, a, b, c;
/*
x:'0',y:'1',z:'_',a:'0',b:'1',c:'2'
(x,a) -> (x,a)
(x,b) -> (y,a)
(x,c) -> (x,b)
(y,a) -> (y,b)
(y,b) -> (x,c)
(y,c) -> (y,c)
(z,a) -> (z,a)
(z,b) -> (x,b)
(z,c) -> (z,c)
*/
const ck = (f1, f2, p1, n1, p2, n2) => (f1(p1, n1) === p2) && (f2(p1, n1) === n2);
(() => {
let count = 0;
for (const p of A) {
for (const n of B) {
// [x, y, z] = p;
[x, y] = p;
[a, b, c] = n;
let rd = [
[x, a, x, a], [x, b, y, a], [x, c, x, b],
[y, a, y, b], [y, b, x, c], [y, c, y, c],
// [z, a, z, a], [z, b, z, b], [z, c, z, c],
]
for (const f1 of FS) {
for (const f2 of FS) {
if (rd.some(k => !ck(f1, f2, k[0], k[1], k[2], k[3]))) continue;
count++;
console.log(`x:${x.toString(2)},y:${y.toString(2)},` +
`a:${a.toString(2)},b:${b.toString(2)},c:${c.toString(2)}`);
console.log(`f1:${f1.toString()}\nf2:${f2.toString()}`)
// if (count > 20) return null;
}
}
}
}
console.log('count:', count);
})();
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/jimgo/ThreePlusOneGame.git
git@gitee.com:jimgo/ThreePlusOneGame.git
jimgo
ThreePlusOneGame
Three Plus One Game
master

搜索帮助