标签:
剧情提要:正剧开始:
星历2016年04月28日 10:41:37, 银河系厄尔斯星球中华帝国江南行省。
[工程师阿伟]正在和[机器小伟]一起研究[对称与群]。
<span style="font-size:18px;">>>> 乘法表:首行顺序 I --- r1 --- r2 --- r3 --- ρ1 --- ρ2 --- 结果: I --- ,r1 --- ,r2 --- ,r3 --- ,ρ1 --- ,ρ2 --- , r1 --- ,I --- ,ρ1 --- ,ρ2 --- ,r2 --- ,r3 --- , r2 --- ,ρ2 --- ,I --- ,ρ1 --- ,r3 --- ,r1 --- , r3 --- ,ρ1 --- ,ρ2 --- ,I --- ,r1 --- ,r2 --- , ρ1 --- ,r3 --- ,r1 --- ,r2 --- ,ρ2 --- ,I --- , ρ2 --- ,r2 --- ,r3 --- ,r1 --- ,I --- ,ρ1 --- , #三角形所有变换 def tmp(): a0 = [1, 2, 3]; allTransfer = [# = C(3, 2) [1, 2, 3],#I [1, 3, 2], #r1 [3, 2, 1], #r2 [2, 1, 3], #r3 [2, 3, 1], #rou1 [3, 1, 2], #rou2 ]; sTable = ['I', 'r1', 'r2', 'r3', 'ρ1', 'ρ2']; #总变化数 N = 6; print('乘法表:首行顺序'); for i in range(N): print(sTable[i], ' --- ', end = ''); print('结果:'); #乘法表 for n in range(N): print(''); for m in range(N): a1 = allTransfer[n]; a2 = allTransfer[m]; b0 = [0]*len(a0); for i in range(len(b0)): b0[i] = a0[a1[i]-1]; b1 = [0]*len(a0); for i in range(len(b1)): b1[i] = b0[a2[i]-1]; for i in range(N): if (b1 == allTransfer[i]): print(sTable[i], ' --- ', end = ','); break;</span>
<span style="font-size:18px;">乘法表:首行顺序 I --- r1 --- r2 --- r3 --- r4 --- ρ1 --- ρ2 --- ρ3 --- 结果: I --- ,r1 --- ,r2 --- ,r3 --- ,r4 --- ,ρ1 --- ,ρ2 --- ,ρ3 --- , r1 --- ,I --- ,ρ3 --- ,ρ2 --- ,ρ1 --- ,r4 --- ,r3 --- ,r2 --- , r2 --- ,ρ1 --- ,I --- ,ρ3 --- ,ρ2 --- ,r1 --- ,r4 --- ,r3 --- , r3 --- ,ρ2 --- ,ρ1 --- ,I --- ,ρ3 --- ,r2 --- ,r1 --- ,r4 --- , r4 --- ,ρ3 --- ,ρ2 --- ,ρ1 --- ,I --- ,r3 --- ,r2 --- ,r1 --- , ρ1 --- ,r2 --- ,r3 --- ,r4 --- ,r1 --- ,ρ2 --- ,ρ3 --- ,I --- , ρ2 --- ,r3 --- ,r4 --- ,r1 --- ,r2 --- ,ρ3 --- ,I --- ,ρ1 --- , ρ3 --- ,r4 --- ,r1 --- ,r2 --- ,r3 --- ,I --- ,ρ1 --- ,ρ2 --- , #正方形所有变换 def tmp2(): a0 = [1, 2, 3, 4]; allTransfer = [ [1, 2, 3, 4],#I [3,2,1,4], #r1 [4,3,2,1], #r2 [1,4,3,2], #r3 [2,1,4,3], #r4 [2,3,4,1], #rou1 [3,4,1,2], #rou2 [4,1,2,3], #rou3 ]; sTable = ['I', 'r1', 'r2', 'r3','r4','ρ1', 'ρ2', 'ρ3']; #总变化数 N = 8; print('乘法表:首行顺序'); for i in range(N): print(sTable[i], ' --- ', end = ''); print('结果:'); #乘法表 for n in range(N): print(''); for m in range(N): a1 = allTransfer[n]; a2 = allTransfer[m]; b0 = [0]*len(a0); for i in range(len(b0)): b0[i] = a0[a1[i]-1]; b1 = [0]*len(a0); for i in range(len(b1)): b1[i] = b0[a2[i]-1]; for i in range(N): if (b1 == allTransfer[i]): print(sTable[i], ' --- ', end = ','); break;</span>
<span style="font-size:18px;">def tmp(): N = 4; originArray = [0]*N; for i in range(N): originArray[i] = i+1; result = flip(originArray, 2); print('原:',originArray); print('变:', result); for i in range(1, 4): result = rotate(originArray, i); print('原:',originArray); print('变:', result); #翻转(反射) #array 和 不动的顶点序号,从1计数 #如三角形是1, 2, 3 def flip(array, vertex): if (vertex <= 0): return array; vertex -= 1; size = len(array); newArray = [0]*size; if (size == 3): for i in range(size): newArray[(vertex-i)%size] = array[(vertex+i)%size]; elif (size == 4): #正方形,实在看不出映射规律,只能穷举 if (vertex == 1): return [array[2], array[1], array[0], array[3]]; elif (vertex == 2): return [array[3], array[2], array[1], array[0]]; elif (vertex == 3): return [array[0], array[3], array[2], array[1]]; elif (vertex == 4): return [array[1], array[0], array[3], array[2]]; else: return array; return newArray; #旋转 #顶点数指从原位置逆时针旋转过几个顶点 #取值范围是从1 ~ 顶点数-1 def rotate(array, vertex): if (vertex <= 0): return array; size = len(array); newArray = [0]*size; for i in range(size): newArray[i] = array[(vertex+i)%size]; return newArray; if __name__ == '__main__': tmp();</span>
<span style="font-size:18px;">>>> [3, 1, 2] #例 def tmp(): a0 = [1, 2, 3]; a1 = [1, 3, 2]; a2 = [2, 1, 3]; b0 = [0]*len(a0); for i in range(len(b0)): b0[i] = a0[a1[i]-1]; b1 = [0]*len(a0); for i in range(len(b1)): b1[i] = b0[a2[i]-1]; print(b1); ####### >>> [2, 3, 1] a0 = [1, 2, 3]; a1 = [2, 1,3]; a2 = [1, 3, 2]; </span>
<span style="font-size:18px;">>>> 首行是: 0 ---- 1 ---- 2 ---- 3 结果: 0 ---- 1 ---- 2 ---- 3 ---- 1 ---- 2 ---- 3 ---- 0 ---- 2 ---- 3 ---- 0 ---- 1 ---- 3 ---- 0 ---- 1 ---- 2 ---- def tmp3(): a = [0, 1, 2, 3]; b = a; print('首行是:', ' 0 ---- 1 ---- 2 ---- 3', '结果:'); for i in range(4): print(''); for j in range(4): print((a[i]+b[j])%4, ' ---- ', end = ''); if __name__ == '__main__': tmp3();</span>
<span style="font-size:18px;">>>> [0, 0] --- [0, 1] --- [0, 2] --- [1, 0] --- [1, 1] --- [1, 2] --- [0, 1] --- [0, 2] --- [0, 0] --- [1, 1] --- [1, 2] --- [1, 0] --- [0, 2] --- [0, 0] --- [0, 1] --- [1, 2] --- [1, 0] --- [1, 1] --- [1, 0] --- [1, 1] --- [1, 2] --- [0, 0] --- [0, 1] --- [0, 2] --- [1, 1] --- [1, 2] --- [1, 0] --- [0, 1] --- [0, 2] --- [0, 0] --- [1, 2] --- [1, 0] --- [1, 1] --- [0, 2] --- [0, 0] --- [0, 1] --- def tmp4(): a = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2]]; b = a; for i in range(6): print(''); for j in range(6): x = (a[i][0]+b[j][0])%2; y = (a[i][1]+b[j][1])%3; print([x, y], ' --- ', end=''); </span>
[人叫板老师]是很让小伟无语的,就这功法的难度,要是结丹期修士不被弄晕,
那绝对是个天才。
本节到此结束,欲知后事如何,请看下回分解。
标签:
原文地址:http://blog.csdn.net/mwsister/article/details/51272401