魔方的原理是什么?( 六 )


众所周知的 ”七步公式还原法“(层先法) 就包括了从这些公式中选出来的 一组基础公式(包括上面提到的 公式ABCD) 。(七步公式还原法 。已经有条友在回答中详细介绍过了 。我这里就不累述了 。)
不知不觉 。已经写了 5千余字了 。关于魔法群还有很多更深入的内容 。例如:上帝数 等 。由于篇幅有限 。这里不能一一展开 。以后有机会再说 。
(小石头 。数学水平有限 。出错在所难免 。希望各位老师和同学批评指正 。)
(补充 2019/10/30)
我将辅助工具的代码放在这里 。以便想要自己试验的条友复制粘贴 。
运行环境:chrome 浏览器;
文件名:rc.html 。包含代码:
<script>const s0 = [[1, 2, 3, 4, 5, 6, 7, 8],[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],[0, 0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]; const U = [[[1, 2, 3, 4]],[[1, 4, 3, 2]],[0, 0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];const D = [[[5, 8, 7, 6]],[[9, 10, 11, 12]],[0, 0, 0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];const F = [[[1, 6, 7, 2]],[[3, 8, 11, 7]],[1, 2, 0, 0, 0, 2, 1, 0],[0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0]];const B = [[[3, 8, 5, 4]],[[1, 6, 9, 5]],[0, 0, 1, 2, 1, 0, 0, 2],[1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0]];const L = [[[1, 4, 5, 6]],[[4, 5, 12, 8]],[2, 0, 0, 1, 2, 1, 0, 0],[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];const R = [[[2, 7, 8, 3]],[[2, 7, 10, 6]],[0, 1, 2, 0, 0, 0, 2, 1],[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];function perform(state, ... operations) {for(var g of operations) {var newstate = [g[0].reduce((l, c) => permute(l, c), state[0]),g[1].reduce((l, c) => permute(l, c), state[1])];newstate[2] = turn(state[0], state[2], newstate[0], g[2], 3);newstate[3] = turn(state[1], state[3], newstate[1], g[3], 2);state = newstate;}return state;}function permute(location, cycle) {var newlocation = Array.from(location);for(var i = 0; i < cycle.length - 1; i++) {newlocation[cycle[i] - 1] = newlocation[cycle[i+1] - 1];}newlocation[cycle[cycle.length - 1] - 1] = location[cycle[0] - 1];return newlocation ;}function turn(oldlocation, oldorientation, newlocation, spin, mod) {var neworientation = [];for (var i = 0; i < newlocation.length; i++) {var j = oldlocation.indexOf(newlocation[i]);neworientation[i] = (oldorientation[j] + spin[i]) % mod;}return neworientation;}function parse(state) {return [parse_cycle(state[0]), parse_cycle(state[1]),Array.from(state[2]), Array.from(state[3])];}function parse_cycle(location) {var flags = [], cycles = [];for (var i = 0; i < location.length; i ++) {if (i + 1 != location[i] && !flags[i]) {var cycle = [i + 1, location[i]], j = location[i] - 1;while(true) {flags[j] = 1;if (location[j] == i + 1) break;cycle.push(location[j]);j = location[j] - 1;}cycles.push(cycle);}}return cycles;}function compose(... operations) {return parse(perform(s0, ... operations));}const str = arr => arr.reduce((s, x) => s + (x[0] instanceof Array ? '[(' + x.map(y => y.join(' ')).join(')(') + ')]' : (x.length == 0 ? '[]' : '(' + x.join() + ')')), '').replace('(0,0,0,0,0,0,0,0)', '()').replace('(0,0,0,0,0,0,0,0,0,0,0,0)', '()');const c = (... ops) => str(compose(... ops)); const UU = compose(U, U), UUU = compose(U, U, U);const DD = compose(D, D), DDD = compose(D, D, D);const FF = compose(F, F), FFF = compose(F, F, F);const BB = compose(B, B), BBB = compose(B, B, B);const LL = compose(L, L), LLL = compose(L, L, L);const RR = compose(R, R), RRR = compose(R, R, R);const cycle = (... x) => [[x], [], s0[2], s0[3]];const M = [[],[[2,4,12,10]],[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1]];const MMM = compose(M, M, M);function perm(arr, callback, index){var swap = (a, i, j, t) => (t = a[i], a[i] = a[j], a[j] = t);index = index || 0;if (index < arr.length) {for (var j = index; j < arr.length; j++) {swap(arr, index, j);if (perm(arr, callback, index + 1)) return true;swap(arr, index, j);}}else {return callback(arr);}}</script>
文件名:rc2.html 。包含代码:

推荐阅读