资源简介
python在群论上的应用,用python计算二阶魔方的上帝之数,求每一步还原情况的算法。
代码片段和文件信息
import time
def mul(ab):
‘‘‘映射复合‘‘‘
n = len(a)
c = [a[b[i]] for i in range(n)]
return tuple(c)
def inv(a):
‘‘‘映射取逆‘‘‘
b = list(a)
for ij in enumerate(a):
b[j]=i
return tuple(b)
#数据初始化
t0 = time.time()
n = 21
e = [i for i in range(n)]
e = tuple(e)
a1 = (13142345601129101118171516871920)
a2 = (01236710118914151213451618192017)
a3 = (03419185678910121613141517121120)
S = (a1a2a3inv(a1)inv(a2)inv(a3)mul(a1a1)mul(a2a2)mul(a3a3))
Sum = 1 # 记录总数
solve = {hash(e)} #记录已解情况
X = [[e][]] #分别存储k步可还原的情形
X_h = [[hash(e)][]] # 对应哈希值
Y_h = [[hash(e)][]] #存储该情形前一状态,用于逆运算
while True
- 上一篇:树莓派http协议onenet平台案例
- 下一篇:Python项目实战
评论
共有 条评论