[ create a new paste ] login | about

Link: http://codepad.org/xLYp8b8L    [ raw code | output | fork ]

Python, pasted on May 22:
#EO EO EO EO    CO  CO  CO  CO      EP EP EP EP     CP  CP  CP  CP
#UF UR UB UL    UFR URB UBL ULF     UF UR UB UL     UFR URB UBL ULF

algs = [[0,0,0,0, 0,0,0,0, 0,1,2,3, 0,1,2,3],     #do nothing
[0,0,0,0, 0,0,0,0, 0,1,2,3, 3,0,2,1],             #Aclock           lala
[0,0,0,0, 0,0,0,0, 0,1,2,3, 1,3,2,0],             #Acounter         lala
[0,0,0,0, 0,0,0,0, 2,3,0,1, 0,1,2,3],             #H
[0,0,0,0, 0,0,0,0, 1,0,2,3, 1,0,2,3],             #coolJ
[0,0,0,0, 0,0,0,0, 1,0,2,3, 0,2,1,3],             #goodR
[0,0,0,0, 0,0,0,0, 0,3,2,1, 1,0,2,3],             #T
[0,0,0,0, 0,0,0,0, 1,3,2,0, 0,1,2,3],             #U (R2 U)         lala
[0,0,0,0, 0,0,0,0, 3,0,2,1, 0,1,2,3]]             #U (R U')         lala
algNames = ["skip", "A(clockwise)", "A(counter-clockwise)", "H", "CoolJ", "goodR", "t", "U(R2 U)", "U(R U')"]

cases = [[0,0,0,0, 0,0,0,0, 0,1,2,3, 0,1,2,3],     #do nothing
[0,0,0,0, 0,0,0,0, 0,1,2,3, 3,0,2,1],             #Aclock           lala
[0,0,0,0, 0,0,0,0, 0,1,2,3, 1,3,2,0],             #Acounter         lala
[0,0,0,0, 0,0,0,0, 0,1,2,3, 1,0,3,2],             #E
[0,0,0,0, 0,0,0,0, 2,1,0,3, 1,0,2,3],             #F
[0,0,0,0, 0,0,0,0, 0,3,1,2, 0,2,3,1],             #G1
[0,0,0,0, 0,0,0,0, 0,2,3,1, 0,3,1,2],             #G2
[0,0,0,0, 0,0,0,0, 0,2,3,1, 2,0,1,3],             #G3
[0,0,0,0, 0,0,0,0, 0,3,1,2, 1,2,0,3],             #G4
[0,0,0,0, 0,0,0,0, 2,3,0,1, 0,1,2,3],             #H
[0,0,0,0, 0,0,0,0, 1,0,2,3, 1,0,2,3],             #coolJ
[0,0,0,0, 0,0,0,0, 0,1,3,2, 0,2,1,3],             #mehJ
[0,0,0,0, 0,0,0,0, 0,3,2,1, 0,3,2,1],             #mehN
[0,0,0,0, 0,0,0,0, 2,1,0,3, 0,3,2,1],             #terribadN
[0,0,0,0, 0,0,0,0, 1,0,2,3, 0,2,1,3],             #goodR
[0,0,0,0, 0,0,0,0, 3,1,2,0, 0,2,1,3],             #badR
[0,0,0,0, 0,0,0,0, 0,3,2,1, 1,0,2,3],             #T
[0,0,0,0, 0,0,0,0, 1,3,2,0, 0,1,2,3],             #U (R2 U)         lala
[0,0,0,0, 0,0,0,0, 3,0,2,1, 0,1,2,3],             #U (R U')         lala
[0,0,0,0, 0,0,0,0, 0,2,1,3, 2,1,0,3],             #V
[0,0,0,0, 0,0,0,0, 0,1,3,2, 2,1,0,3],             #Y
[0,0,0,0, 0,0,0,0, 1,0,3,2, 0,1,2,3]]             #Z
caseNames = ["nothing", "aclock", "acounter", "e", "f", "g1", "g2", "g3", "g4", "h", "coolj", "badj", "regN", "badN", "goodR", "badR", "t", "U(R2 U)", "U(R U')", "v", "y", "z"]

auf = [0,0,0,0, 0,0,0,0, 1,2,3,0, 1,2,3,0]

##################################################
class MyCube:
    """A virtual 3x3x3 matrix"""
    def __init__(self):
        self.edges =    ["UF", "UR", "UB", "UL"]
        self.corners =  ["UFR", "URB", "UBL", "ULF"]

    def doAlg(self, alg):
        for eo in range(0,4):
            if (alg[eo] == 1):
                self.edges[eo] = self.edges[eo][::-1]       #flip an edge

        for co in range(4,8):
            if(alg[co] == 1):                               #twist clockwise
                self.corners[co-4] = self.corners[co-4][-1] + self.corners[:-1]
            elif (alg[co] == 2):                            #twist counter-clockwise (clockwise twice)....lazy, I'll fix this sometime
                self.corners[co-4] = self.corners[co-4][-1] + self.corners[:-1]
                self.corners[co-4] = self.corners[co-4][-1] + self.corners[:-1]

        tempEdges = ["","","",""]
        tempCorners = ["","","",""]
        for perm in range(4):
            tempEdges[perm] = self.edges[alg[perm+8]]       #permute edges
            tempCorners[perm] = self.corners[alg[perm+12]]  #permute corners
        self.edges = tempEdges
        self.corners = tempCorners

    def checkSolved(self):
        if (self.edges ==   ["UF", "UR", "UB", "UL"]) and (self.corners == ["UFR", "URB", "UBL", "ULF"]):    return True
        elif (self.edges == ["UR", "UB", "UL", "UF"]) and (self.corners == ["URB", "UBL", "ULF", "UFR"]):  return True
        elif (self.edges == ["UB", "UL", "UF", "UR"]) and (self.corners == ["UBL", "ULF", "UFR", "URB"]):  return True
        elif (self.edges == ["UL", "UF", "UR", "UB"]) and (self.corners == ["ULF", "UFR", "URB", "UBL"]):  return True
        else:                                                                                              return False

    def printStuff(self):
        print self.edges
        print self.corners

    def doAUF(self,n):
        for x in range(0,n):
            self.doAlg(auf)

##def tryToSolve(cube):
##    idfk = 0
##    startCube = MyCube();startCube = cube
##    if startCube.checkSolved():return "already solved"; idfk = 1
##
##    for firstAlg in algs:
##        oneCube = MyCube();oneCube = startCube
##        oneCube.doAlg(firstAlg)
##        if oneCube.checkSolved():return "solved after one alg"; idfk = 2
##
##        for midAUF in range(4):
##            oneCube.doAUF()
##            for secondAlg in algs:
##                twoCube = MyCube();twoCube = oneCube
##                twoCube.doAlg(secondAlg)
##                if twoCube.checkSolved():return "solved after two algs"; idfk = 3
##
##    if idfk == 0:
##        return "never solved :("

def tryToSolveInefficiently(ctemp):                                             #this can be vastly improved using shit that's commented out,...if/when I fix it.
    for firstAUF in range(4):
        for firstAlg in range(0,len(algs)):
            for secondAUF in range(4):
                for secondAlg in range(0,len(algs)):
                    lulzCube = MyCube(); lulzCube.doAlg(cases[ctemp])           #the case we're working on
                    lulzCube.doAUF(firstAUF)                                    #rotate the top layer
                    lulzCube.doAlg(algs[firstAlg])                              #do an alg ("nothing" happens to be one of the algs!)
                    lulzCube.doAUF(secondAUF)                                   #rotate the top layer again
                    lulzCube.doAlg(algs[secondAlg])                             #do another alg (again, "nothing" is a possibility, making it possible to really only be doing one alg.
                    if lulzCube.checkSolved():                                  #if solved, using what algs?
                        return "Solved with U" + str(firstAUF) + " " + algNames[firstAlg] + " U" + str(secondAUF) + " followed by " + algNames[secondAlg]
    return "unsolved :("


##################################################
import time
start = time.time()
c = 0                                   #what case are we working on? for calling algNames
for case in cases:                      #for every case we need to solve
    idk = MyCube(); idk.doAlg(case)     #this is the case we're going to solve
    print 'scramble; ', caseNames[c], case            #print out what we call it [ex; "T perm"], the configuration, and incremen our c variable
    idk.printStuff()                    #print out the case

    print tryToSolveInefficiently(c);     c=c+1

    print
print  time.time()-start


Output:
scramble;  nothing [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0, 1, 2, 3]
['UF', 'UR', 'UB', 'UL']
['UFR', 'URB', 'UBL', 'ULF']
Solved with U0 skip U0 followed by skip

scramble;  aclock [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 3, 0, 2, 1]
['UF', 'UR', 'UB', 'UL']
['ULF', 'UFR', 'UBL', 'URB']
Solved with U0 skip U0 followed by A(counter-clockwise)

scramble;  acounter [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 1, 3, 2, 0]
['UF', 'UR', 'UB', 'UL']
['URB', 'ULF', 'UBL', 'UFR']
Solved with U0 skip U0 followed by A(clockwise)

scramble;  e [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 1, 0, 3, 2]
['UF', 'UR', 'UB', 'UL']
['URB', 'UFR', 'ULF', 'UBL']
Solved with U0 A(clockwise) U3 followed by A(clockwise)

scramble;  f [0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 3, 1, 0, 2, 3]
['UB', 'UR', 'UF', 'UL']
['URB', 'UFR', 'UBL', 'ULF']
Solved with U0 A(clockwise) U3 followed by t

scramble;  g1 [0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 2, 0, 2, 3, 1]
['UF', 'UL', 'UR', 'UB']
['UFR', 'UBL', 'ULF', 'URB']
Solved with U0 H U2 followed by goodR

scramble;  g2 [0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 1, 0, 3, 1, 2]
['UF', 'UB', 'UL', 'UR']
['UFR', 'ULF', 'URB', 'UBL']
Solved with U0 CoolJ U3 followed by U(R2 U)

scramble;  g3 [0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 1, 2, 0, 1, 3]
['UF', 'UB', 'UL', 'UR']
['UBL', 'UFR', 'URB', 'ULF']
Solved with U0 U(R U') U3 followed by t

scramble;  g4 [0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 2, 1, 2, 0, 3]
['UF', 'UL', 'UR', 'UB']
['URB', 'UBL', 'UFR', 'ULF']
Solved with U0 A(clockwise) U0 followed by goodR

scramble;  h [0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 0, 1, 0, 1, 2, 3]
['UB', 'UL', 'UF', 'UR']
['UFR', 'URB', 'UBL', 'ULF']
Solved with U0 skip U0 followed by H

scramble;  coolj [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 3, 1, 0, 2, 3]
['UR', 'UF', 'UB', 'UL']
['URB', 'UFR', 'UBL', 'ULF']
Solved with U0 skip U0 followed by CoolJ

scramble;  badj [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 2, 0, 2, 1, 3]
['UF', 'UR', 'UL', 'UB']
['UFR', 'UBL', 'URB', 'ULF']
Solved with U0 A(clockwise) U1 followed by U(R U')

scramble;  regN [0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 1, 0, 3, 2, 1]
['UF', 'UL', 'UB', 'UR']
['UFR', 'ULF', 'UBL', 'URB']
Solved with U0 A(clockwise) U0 followed by t

scramble;  badN [0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 3, 0, 3, 2, 1]
['UB', 'UR', 'UF', 'UL']
['UFR', 'ULF', 'UBL', 'URB']
Solved with U0 A(counter-clockwise) U3 followed by t

scramble;  goodR [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 3, 0, 2, 1, 3]
['UR', 'UF', 'UB', 'UL']
['UFR', 'UBL', 'URB', 'ULF']
Solved with U0 skip U0 followed by goodR

scramble;  badR [0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 2, 0, 0, 2, 1, 3]
['UL', 'UR', 'UB', 'UF']
['UFR', 'UBL', 'URB', 'ULF']
Solved with U0 A(clockwise) U2 followed by U(R U')

scramble;  t [0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 1, 1, 0, 2, 3]
['UF', 'UL', 'UB', 'UR']
['URB', 'UFR', 'UBL', 'ULF']
Solved with U0 skip U0 followed by t

scramble;  U(R2 U) [0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 2, 0, 0, 1, 2, 3]
['UR', 'UL', 'UB', 'UF']
['UFR', 'URB', 'UBL', 'ULF']
Solved with U0 skip U0 followed by U(R U')

scramble;  U(R U') [0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 2, 1, 0, 1, 2, 3]
['UL', 'UF', 'UB', 'UR']
['UFR', 'URB', 'UBL', 'ULF']
Solved with U0 skip U0 followed by U(R2 U)

scramble;  v [0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 3, 2, 1, 0, 3]
['UF', 'UB', 'UR', 'UL']
['UBL', 'URB', 'UFR', 'ULF']
Solved with U0 goodR U3 followed by CoolJ

scramble;  y [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 2, 2, 1, 0, 3]
['UF', 'UR', 'UL', 'UB']
['UBL', 'URB', 'UFR', 'ULF']
Solved with U0 CoolJ U2 followed by t

scramble;  z [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 2, 0, 1, 2, 3]
['UR', 'UF', 'UL', 'UB']
['UFR', 'URB', 'UBL', 'ULF']
Solved with U0 t U2 followed by A(counter-clockwise)

0.135545015335


Create a new paste based on this one


Comments: