1. algDict = {0: '0 ', 1: 'U ', 2: 'U ', 3: 'H ', 4: 'Z ', 5: 'A ',
2. 6: 'A ', 7: 'E ', 8: 'J ', 9: 'J ', 10: 'R ', 11: 'R ',
3. 12: 'G ', 13: 'G ', 14: 'G ', 15: 'G ', 16: 'N ', 17: 'N ',
4. 18: 'T ', 19: 'Y ', 20: 'F ', 21: 'V '}
5. highest = 0
6.
7. algs = ["",
8. "R' U R' U' R' U' R' U R U R2",
9. "R U' R U R U R U' R' U' R2",
10. "R2 U2 R U2 R2 U2 R2 U2 R U2 R2",
11. "R2 U R2 U' R2 F2 R2 U' F2 U R2 F2",
12. "R U' R F2 R' U R' U' R2 F2 R2",
13. "R2 F2 R2 U R U' R F2 R' U R'",
14. "R U R' U R' U' R F' R U R' U' R' F R2 U' R2 U R",
15. "F' U2 R' U F U' F' U' R U' F",
16. "R U R' F' R U R' U' R' F R2 U' R'",
17. "R' U2 R U2 R' F R U R' U' R' F' R2",
18. "F' R' U' R F' R' U F' U' F' U F R F2",
19. "F2 R2 U' R' U' R F2 R' U R F2 U R2 F2",
20. "F2 R2 U' F2 R' U' R F2 R' U R U R2 F2",
21. "R' U' R2 U' R2 U' R U2 R2 F U R' U' R F' R",
22. "R' F R' U R U' F' R2 U2 R' U R2 U R2 U R",
23. "F' R U R' U' R' F R2 F U' R' U' R U F' R",
24. "R' U R' F R F' R U' R' F' U F R U R' U' R",
25. "R U R' U' R' F R2 U' R' U' R U R' F'",
26. "F R U' R' U' R U R' F' R U R' U' R' F R F'",
27. "F' U2 F' U' R' F' R2 U' R' U R' F R U' F",
28. "R U' R U F R F2 U F U' F R' F' R'"]
29. #21, 14, 9
30.
31. def tryOne(aTemp, this): #string of alg trying, string of alg trying to solve
32. wtf = MyCube(); wtf.doAlg(this); wtf.doUp()
33. for try1 in range(4):
34. wtf.doU(); wtf2 = wtf
35. wtf2.doAlg(aTemp)
36.
37. if wtf2.checkSolved(): return True
38.
39. return False
40.
41. def tryTwo(aTemp, bTemp, this):
42. now = MyCube(); now.doAlg(this); now.doUp()
43. for try1 in range(4):
44. now.doU(); mow = now
45. mow.doAlg(aTemp)
46. for try2 in range(4):
47. mow.doU(); oow = mow
48. oow.doAlg(bTemp)
49. if oow.checkSolved(): return True
50.
51. return False
52.
53. def tryCombo(a, b, listNow):
54. for alg in range(0, len(algs)):
55. if listNow[alg] == 0:
56.
57. aCube = MyCube(); aCube.doAlg(algs[alg])
58.
59. if aCube.checkSolved(): #basically, check if it's already good (case algs[0])
60. listNow[alg] = True; print 'try000 solved: ', algs[alg]; continue
61.
62. if tryOne(a, algs[alg]): listNow[alg] = True; print 'try1 a solved: ', algs[alg]; continue
63. if tryOne(b, algs[alg]): listNow[alg] = True; print 'try1 b solved: ', algs[alg]; continue
64.
65. if tryTwo(a, b, algs[alg]): listNow[alg] = True; print 'try2ab solved: ', algs[alg]; continue
66. if tryTwo(b, a, algs[alg]): listNow[alg] = True; print 'try2ba solved: ', algs[alg]; continue
67.
68. if tryTwo(a, a, algs[alg]): listNow[alg] = True; print 'try2aa solved: ', algs[alg]; continue
69. if tryTwo(b, b, algs[alg]): listNow[alg] = True; print 'try2bb solved: ', algs[alg]; continue
70.
71. ## if aCube.checkSolved(): #basically, check if it's already good (case algs[0])
72. ## listNow[alg] = 1; continue
73. ##
74. ## elif tryOne(a, algs[alg]): listNow[alg] = 1; continue
75. ## elif tryOne(b, algs[alg]): listNow[alg] = 1; continue
76. ##
77. ## elif tryTwo(a, b, algs[alg]): listNow[alg] = 1; continue
78. ## elif tryTwo(b, a, algs[alg]): listNow[alg] = 1; continue
79. ##
80. ## elif tryTwo(a, a, algs[alg]): listNow[alg] = 1; continue
81. ## elif tryTwo(b, b, algs[alg]): listNow[alg] = 1; continue
82.
83. #else: return listNow
84.
85. return listNow
86.
87. ##################################################
88. class MyCube:
89. """A virtual 3x3x3 matrix"""
90. def __init__(self):
91. self.uSide = ['U', 'U', 'U', 'U', 'U', 'U', 'U', 'U'] #URF, UF, etc
92. self.fSide = ['F', 'F', 'F', 'F', 'F', 'F', 'F', 'F'] #FRD, FD, etc
93. self.lSide = ['L', 'L', 'L', 'L', 'L', 'L', 'L', 'L'] #LFD, LD, etc
94. self.bSide = ['B', 'B', 'B', 'B', 'B', 'B', 'B', 'B'] #BRD, BD, etc
95. self.rSide = ['R', 'R', 'R', 'R', 'R', 'R', 'R', 'R'] #RBD, RD, etc
96. self.dSide = ['D', 'D', 'D', 'D', 'D', 'D', 'D', 'D'] #DBR, DR, etc
97.
98.
99. def doU(self):
100.
101. self.uSide[0], self.uSide[1], self.uSide[2], self.uSide[3], self.uSide[4], self.uSide[5], self.uSide[6], self.uSide[7] = self.uSide[6], self.uSide[7], self.uSide[0], self.uSide[1], self.uSide[2], self.uSide[3], self.uSide[4], self.uSide[5]
102.
103. self.fSide[5], self.lSide[5], self.bSide[1], self.rSide[5] = self.rSide[5], self.fSide[5], self.lSide[5], self.bSide[1]
104. self.fSide[6], self.lSide[6], self.bSide[2], self.rSide[6] = self.rSide[6], self.fSide[6], self.lSide[6], self.bSide[2]
105. self.fSide[7], self.lSide[7], self.bSide[3], self.rSide[7] = self.rSide[7], self.fSide[7], self.lSide[7], self.bSide[3]
106.
107. def doUp(self):
108. self.uSide[6], self.uSide[7], self.uSide[0], self.uSide[1], self.uSide[2], self.uSide[3], self.uSide[4], self.uSide[5] = self.uSide[0], self.uSide[1], self.uSide[2], self.uSide[3], self.uSide[4], self.uSide[5], self.uSide[6], self.uSide[7]
109.
110. self.rSide[5], self.fSide[5], self.lSide[5], self.bSide[1] = self.fSide[5], self.lSide[5], self.bSide[1], self.rSide[5]
111. self.rSide[6], self.fSide[6], self.lSide[6], self.bSide[2] = self.fSide[6], self.lSide[6], self.bSide[2], self.rSide[6]
112. self.rSide[7], self.fSide[7], self.lSide[7], self.bSide[3] = self.fSide[7], self.lSide[7], self.bSide[3], self.rSide[7]
113.
114. def doR(self):
115.
116. self.rSide[0], self.rSide[1], self.rSide[2], self.rSide[3], self.rSide[4], self.rSide[5], self.rSide[6], self.rSide[7] = self.rSide[6], self.rSide[7], self.rSide[0], self.rSide[1], self.rSide[2], self.rSide[3], self.rSide[4], self.rSide[5]
117.
118. self.fSide[7], self.uSide[7], self.bSide[7], self.dSide[7] = self.dSide[7], self.fSide[7], self.uSide[7], self.bSide[7]
119. self.fSide[0], self.uSide[0], self.bSide[0], self.dSide[0] = self.dSide[0], self.fSide[0], self.uSide[0], self.bSide[0]
120. self.fSide[1], self.uSide[1], self.bSide[1], self.dSide[1] = self.dSide[1], self.fSide[1], self.uSide[1], self.bSide[1]
121.
122. def doRp(self):
123. self.rSide[6], self.rSide[7], self.rSide[0], self.rSide[1], self.rSide[2], self.rSide[3], self.rSide[4], self.rSide[5] = self.rSide[0], self.rSide[1], self.rSide[2], self.rSide[3], self.rSide[4], self.rSide[5], self.rSide[6], self.rSide[7]
124.
125. self.dSide[7], self.fSide[7], self.uSide[7], self.bSide[7] = self.fSide[7], self.uSide[7], self.bSide[7], self.dSide[7]
126. self.dSide[0], self.fSide[0], self.uSide[0], self.bSide[0] = self.fSide[0], self.uSide[0], self.bSide[0], self.dSide[0]
127. self.dSide[1], self.fSide[1], self.uSide[1], self.bSide[1] = self.fSide[1], self.uSide[1], self.bSide[1], self.dSide[1]
128.
129. def doF(self):
130. self.fSide[0], self.fSide[1], self.fSide[2], self.fSide[3], self.fSide[4], self.fSide[5], self.fSide[6], self.fSide[7] = self.fSide[6], self.fSide[7], self.fSide[0], self.fSide[1], self.fSide[2], self.fSide[3], self.fSide[4], self.fSide[5]
131.
132. self.uSide[1], self.rSide[3], self.dSide[5], self.lSide[7] = self.lSide[7], self.uSide[1], self.rSide[3], self.dSide[5]
133. self.uSide[2], self.rSide[4], self.dSide[6], self.lSide[0] = self.lSide[0], self.uSide[2], self.rSide[4], self.dSide[6]
134. self.uSide[3], self.rSide[5], self.dSide[7], self.lSide[1] = self.lSide[1], self.uSide[3], self.rSide[5], self.dSide[7]
135.
136. def doFp(self):
137. self.fSide[6], self.fSide[7], self.fSide[0], self.fSide[1], self.fSide[2], self.fSide[3], self.fSide[4], self.fSide[5] = self.fSide[0], self.fSide[1], self.fSide[2], self.fSide[3], self.fSide[4], self.fSide[5], self.fSide[6], self.fSide[7]
138.
139. self.lSide[7], self.uSide[1], self.rSide[3], self.dSide[5] = self.uSide[1], self.rSide[3], self.dSide[5], self.lSide[7]
140. self.lSide[0], self.uSide[2], self.rSide[4], self.dSide[6] = self.uSide[2], self.rSide[4], self.dSide[6], self.lSide[0]
141. self.lSide[1], self.uSide[3], self.rSide[5], self.dSide[7] = self.uSide[3], self.rSide[5], self.dSide[7], self.lSide[1]
142.
143.
144.
145. def doAlg(self, algString):
146. ialg = algString.replace('(', '') #get rid of unwanted
147. ialg = ialg.replace(')', '') # or otherwise unneeded characters
148. ialg = ialg.replace("2'", '2') # incl. whitespace, paren., 2's
149. ialg = ialg.replace(' ', ' ')
150. parts = ialg.split(' ') #Divide the alg up into individual moves
151.
152. for part in parts:
153. if part == 'U': self.doU()
154. elif part == 'U2': self.doU(); self.doU()
155. elif part == "U'": self.doUp()
156.
157. elif part == 'F': self.doF()
158. elif part == 'F2': self.doF(); self.doF()
159. elif part == "F'": self.doFp()
160.
161. elif part == 'R': self.doR()
162. elif part == 'R2': self.doR(); self.doR()
163. elif part == "R'": self.doRp()
164.
165. def printCube(self):
166. print
167. print " ", self.bSide[5] + self.bSide[6] + self.bSide[7]
168. print " ", self.bSide[4] + "b" + self.bSide[0]
169. print " ", self.bSide[3] + self.bSide[2] + self.bSide[1] + '\n'
170.
171. print " ", self.uSide[5] + self.uSide[6] + self.uSide[7]
172. print " ", self.uSide[4] + "u" + self.uSide[0]
173. print " ", self.uSide[3] + self.uSide[2] + self.uSide[1] + '\n'
174.
175. print "" + self.lSide[5] + self.lSide[6] + self.lSide[7], self.fSide[5] + self.fSide[6] + self.fSide[7], self.rSide[5] + self.rSide[6] + self.rSide[7]
176. print "" + self.lSide[4] + 'l' + self.lSide[0], self.fSide[4] + 'f' + self.fSide[0], self.rSide[4] + 'r' + self.rSide[0]
177. print "" + self.lSide[3] + self.lSide[2] + self.lSide[1], self.fSide[3] + self.fSide[2] + self.fSide[1], self.rSide[3] + self.rSide[2] + self.rSide[1] + '\n'
178.
179. print " ", self.dSide[5] + self.dSide[6] + self.dSide[7]
180. print " ", self.dSide[4] + "d" + self.dSide[0]
181. print " ", self.dSide[3] + self.dSide[2] + self.dSide[1] + '\n'
182.
183. def printMin(self):
184. print
185.
186. print " ", self.bSide[3] + self.bSide[2] + self.bSide[1] + '\n'
187.
188. print " ", self.uSide[5] + self.uSide[6] + self.uSide[7]
189. print " ", self.uSide[4] + "u" + self.uSide[0]
190. print " ", self.uSide[3] + self.uSide[2] + self.uSide[1] + '\n'
191.
192. print "" + self.lSide[5] + self.lSide[6] + self.lSide[7], self.fSide[5] + self.fSide[6] + self.fSide[7], self.rSide[5] + self.rSide[6] + self.rSide[7]
193.
194. def checkSolved(self):
195. if self.uSide[0] == self.uSide[1] == self.uSide[2] == self.uSide[3] == self.uSide[4] == self.uSide[5] == self.uSide[6] == self.uSide[7]:
196. if self.fSide[5] == self.fSide[6] == self.fSide[7]:
197. if self.lSide[5] == self.lSide[6] == self.lSide[7]:
198. if self.rSide[5] == self.rSide[6] == self.rSide[7]:
199. if self.bSide[3] == self.bSide[2] == self.bSide[1]:
200. return True
201. return False
202.
203. ##################################################
204. def tryOne(aTemp, this): #string of alg trying, string of alg trying to solve
205. wtf = MyCube(); wtf.doAlg(this); wtf.doUp()
206. for try1 in range(4):
207. wtf.doU(); wtf2 = wtf
208. wtf2.doAlg(aTemp)
209.
210. if wtf2.checkSolved(): return True
211.
212. return False
213.
214. def tryTwo(aTemp, bTemp, this):
215. now = MyCube(); now.doAlg(this); now.doUp()
216. for try1 in range(4):
217. now.doU(); mow = now
218. mow.doAlg(aTemp)
219. for try2 in range(4):
220. mow.doU(); oow = mow
221. oow.doAlg(bTemp)
222. if oow.checkSolved(): return True
223.
224. return False
225.
226. def tryCombo(a, b, c):
227. for alg in range(0, len(algs)):
228.
229. aCube = MyCube(); aCube.doAlg(algs[alg])
230.
231. if aCube.checkSolved(): #basically, check if it's already good (case algs[0])
232. continue
233.
234. elif tryOne(a, algs[alg]): continue
235. elif tryOne(b, algs[alg]): continue
236. elif tryOne(c, algs[alg]): continue
237.
238. elif tryTwo(a, b, algs[alg]): continue
239. elif tryTwo(a, c, algs[alg]): continue
240. elif tryTwo(b, a, algs[alg]): continue
241. elif tryTwo(b, c, algs[alg]): continue
242. elif tryTwo(c, a, algs[alg]): continue
243. elif tryTwo(c, b, algs[alg]): continue
244.
245. elif tryTwo(a, a, algs[alg]): continue
246. elif tryTwo(b, b, algs[alg]): continue
247. elif tryTwo(c, c, algs[alg]): continue
248.
249. else: return False
250.
251. return True
252.
253.
254.
255. count = 0
256. for l1 in range(15):
257. #for l1 in range(len(algs)):
258. #print "L1: ", l1
259. for l2 in range(l1):
260. #print "L2: ", l2,
261. for l3 in range(l2):
262.
263. if tryCombo(algs[l1], algs[l2], algs[l3]):
264. print
265. print "Algs used: ", l1, l2, l3
266. print "Cases solved: " + str(sum(algsDone)) + " out of " + str(len(algs))
267. print algsDone; print
268. highest = sum(algsDone)
Time limit exceeded #stdin #stdout -1s 7172KB
stdin
Standard input is empty
stdout
Standard output is empty