def move(x, perm): if x/3==0 : cS.u(x%3+1, perm) elif x/3==1 : cS.r(x%3+1, perm) elif x/3==2 : cS.f(x%3+1, perm) return perm
def steps(mat, inst): import cubeSfy as cS import cubeRot as cR for k in range(0, 4): if mat[0][0][0][0] == mat[0][1][0][0]: break cR.u(1, mat) cS.u(k, mat) inst.extend(cS.u(-k, mat))
def move(x, perm): if x/3==0 : cS.u(x%3+1, perm) elif x/3==1 : cS.d(x%3+1, perm) elif x/3==2 : cS.l(x%3+1, perm) elif x/3==3 : cS.r(x%3+1, perm) elif x/3==4 : cS.f(x%3+1, perm) elif x/3==5 : cS.b(x%3+1, perm) return perm
def seq_nor(): inst.append(cR.r(1, mat)) # R' inst.append(cR.u(1, mat)) # U' inst.append(cR.r(-1, mat)) # R inst.append(cR.u(1, mat)) # U' inst.append(cR.r(1, mat)) # R' inst.extend(cS.u(2, mat)) # U2 inst.append(cR.r(-1, mat)) # R
def seq_inv(): inst.append(cR.r(1, mat)) # R' inst.extend(cS.u(2, mat)) # U2 inst.append(cR.r(-1, mat)) # R inst.append(cR.u(-1, mat)) # U inst.append(cR.r(1, mat)) # R' inst.append(cR.u(-1, mat)) # U inst.append(cR.r(-1, mat)) # R
def steps(mat, inst): import cubeSfy as cS import cubeRot as cR last_lay = [mat[0][1][0], mat[1][1][0], mat[1][1][1], mat[0][1][1]] ''' last_lay1=[mat[0][0][0], mat[1][0][0], mat[1][0][1], mat[0][0][1]] for i in last_lay : print i print '\n' for i in last_lay1 : print i #''' def seq(): inst.append(cR.r(-1, mat)) # R inst.append(cR.u(1, mat)) # U' inst.append(cR.l(1, mat)) # L' inst.append(cR.u(-1, mat)) # U inst.append(cR.r(1, mat)) # R' inst.append(cR.u(1, mat)) # U' inst.append(cR.l(-1, mat)) # L for j in range(0, 4): if (mat[0][0][0][0] in last_lay[j]) and (mat[0][0][0][1] in last_lay[j]): break for k in range(1, 4): if (mat[1][0][0][0] in last_lay[(j + k) % 4]) and (mat[1][0][0][1] in last_lay[(j + k) % 4]): break for l in range(1, 4): if (mat[1][0][1][0] in last_lay[(j + l) % 4]) and (mat[1][0][1][1] in last_lay[(j + l) % 4]): break #print j, k, l if k == 1 and l == 2: inst.extend(cS.u(-j, mat)) elif k == 2 and l == 1: inst.extend(cS.u(2 - j, mat)) seq() elif k == 2 and l == 3: inst.extend(cS.u(-j - 1, mat)) seq() inst.extend(cS.u(2, mat)) elif k == 3 and l == 2: inst.extend(cS.u(-j - 1, mat)) seq() seq() elif k == 1 and l == 3: inst.extend(cS.u(-j + 1, mat)) seq() elif k == 3 and l == 1: inst.extend(cS.u(-j, mat)) seq() inst.extend(cS.u(2, mat))
def seq_main(): for k in range(0, 4): if mat[0][1][0][2] == 0: break cR.u(1, mat) if mat[1][1][0][0] == 0: cS.u(k, mat) inst.extend(cS.u(-k, mat)) seq_nor() elif mat[1][1][0][1] == 0: cS.u(k, mat) inst.extend(cS.u(-k + 2, mat)) seq_inv()
def steps(mat, inst): import cubeSfy as cS import cubeRot as cR last_lay = [mat[0][1][0], mat[1][1][0], mat[1][1][1], mat[0][1][1]] ''' for i in last_lay : print i #''' def seq_nor(): inst.append(cR.r(1, mat)) # R' inst.append(cR.u(1, mat)) # U' inst.append(cR.r(-1, mat)) # R inst.append(cR.u(1, mat)) # U' inst.append(cR.r(1, mat)) # R' inst.extend(cS.u(2, mat)) # U2 inst.append(cR.r(-1, mat)) # R def seq_inv(): inst.append(cR.r(1, mat)) # R' inst.extend(cS.u(2, mat)) # U2 inst.append(cR.r(-1, mat)) # R inst.append(cR.u(-1, mat)) # U inst.append(cR.r(1, mat)) # R' inst.append(cR.u(-1, mat)) # U inst.append(cR.r(-1, mat)) # R def seq_main(): for k in range(0, 4): if mat[0][1][0][2] == 0: break cR.u(1, mat) if mat[1][1][0][0] == 0: cS.u(k, mat) inst.extend(cS.u(-k, mat)) seq_nor() elif mat[1][1][0][1] == 0: cS.u(k, mat) inst.extend(cS.u(-k + 2, mat)) seq_inv() pos = [] for j in range(0, 4): if last_lay[j][2] == 0: #red pos.append(j) if len(pos) == 1: #print pos[0] seq_main() elif len(pos) == 4: pass elif len(pos) == 2: #print pos[0], pos[1] cS.u(3 - pos[1], mat) if mat[1][1][0][2] == 0: if mat[1][1][1][1] == 0: cS.u(pos[1] - 3, mat) inst.extend(cS.u(3 - pos[1], mat)) seq_nor() else: cS.u(pos[1] - 3, mat) inst.extend(cS.u(5 - pos[1], mat)) seq_inv() else: if mat[1][1][0][0] == 0: cS.u(pos[1] - 3, mat) inst.extend(cS.u(3 - pos[1], mat)) seq_nor() else: cS.u(pos[1] - 3, mat) inst.extend(cS.u(5 - pos[1], mat)) seq_inv() seq_main() elif len(pos) == 0: if mat[1][1][0][0] == 0 and mat[0][1][1][0] == 0: inst.extend(cS.u(2, mat)) seq_inv() elif mat[1][1][0][0] != 0 and mat[0][1][1][0] != 0: seq_nor() else: if mat[1][1][1][0] == 0: seq_nor() else: inst.extend(cS.u(2, mat)) seq_inv() seq_main()