1 Star 0 Fork 0

jimgo/Three Plus One Game

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
findBye2B.js 2.01 KB
一键复制 编辑 原始数据 按行查看 历史
jimgo 提交于 2024-11-06 14:04 . save
const SW = 1<<3;
const B = [];
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);
(() => {
for (let i = 0; i < SW; i++) {
for (let j = 0; j < SW; j++) {
for (let k = 0; k < SW; k++) {
if(i === j || j === k || i === k) continue;
B.push([i, j, k]);
} } }
console.log('B.length',B.length);
for (const f of FS.slice()) {
for (let i = 0; i < SW; i++) {
FS.push((p, n) => f((p & i) , n));
FS.push((p, n) => f((p | i) , n));
FS.push((p, n) => f((p ^ i) , n));
FS.push((p, n) => f(p , (n & i)));
FS.push((p, n) => f(p , (n | i)));
FS.push((p, n) => f(p , (n ^ i)));
}
}
console.log('FS.length:', FS.length);
let count = 0;
for (const p of B) {
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)}`+
` f1:${f1.toString()}\n f2:${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

搜索帮助