-
Notifications
You must be signed in to change notification settings - Fork 0
/
solve.py
302 lines (273 loc) · 17.6 KB
/
solve.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
import moves
from cubeconstants import*
from moves import*
def FINDCORNER(COLOR1,COLOR2,COLOR3):
CORNER1={CUBE[SFRONT][RTOP][CLEFT]:SFRONT,CUBE[SLEFT][RTOP][CRIGHT]:SLEFT,CUBE[STOP][RBOT][CLEFT]:STOP}
CORNER2={CUBE[SRIGHT][RTOP][CLEFT]:SRIGHT,CUBE[SFRONT][RTOP][CRIGHT]:SFRONT,CUBE[STOP][RBOT][CRIGHT]:STOP}
CORNER3={CUBE[SBACK][RTOP][CLEFT]:SBACK,CUBE[SRIGHT][RTOP][CRIGHT]:SRIGHT,CUBE[STOP][RTOP][CRIGHT]:STOP}
CORNER4={CUBE[SLEFT][RTOP][CLEFT]:SLEFT,CUBE[SBACK][RTOP][CRIGHT]:SBACK,CUBE[STOP][RTOP][CLEFT]:STOP}
CORNER5={CUBE[SFRONT][RBOT][CLEFT]:SFRONT,CUBE[SLEFT][RBOT][CRIGHT]:SLEFT,CUBE[SUNDER][RTOP][CLEFT]:SUNDER}
CORNER6={CUBE[SRIGHT][RBOT][CLEFT]:SRIGHT,CUBE[SFRONT][RBOT][CRIGHT]:SFRONT,CUBE[SUNDER][RTOP][CRIGHT]:SUNDER}
CORNER7={CUBE[SBACK][RBOT][CLEFT]:SBACK,CUBE[SRIGHT][RBOT][CRIGHT]:SRIGHT,CUBE[SUNDER][RBOT][CRIGHT]:SUNDER}
CORNER8={CUBE[SLEFT][RBOT][CLEFT]:SLEFT,CUBE[SBACK][RBOT][CRIGHT]:SBACK,CUBE[SUNDER][RBOT][CLEFT]:SUNDER}
if frozenset([COLOR1,COLOR2,COLOR3])==frozenset(CORNER1.keys()):
return [CORNER1[COLOR1],CORNER1[COLOR2],CORNER1[COLOR3]]
if frozenset([COLOR1,COLOR2,COLOR3])==frozenset(CORNER2.keys()):
return [CORNER2[COLOR1],CORNER2[COLOR2],CORNER2[COLOR3]]
if frozenset([COLOR1,COLOR2,COLOR3])==frozenset(CORNER3.keys()):
return [CORNER3[COLOR1],CORNER3[COLOR2],CORNER3[COLOR3]]
if frozenset([COLOR1,COLOR2,COLOR3])==frozenset(CORNER4.keys()):
return [CORNER4[COLOR1],CORNER4[COLOR2],CORNER4[COLOR3]]
if frozenset([COLOR1,COLOR2,COLOR3])==frozenset(CORNER5.keys()):
return [CORNER5[COLOR1],CORNER5[COLOR2],CORNER5[COLOR3]]
if frozenset([COLOR1,COLOR2,COLOR3])==frozenset(CORNER6.keys()):
return [CORNER6[COLOR1],CORNER6[COLOR2],CORNER6[COLOR3]]
if frozenset([COLOR1,COLOR2,COLOR3])==frozenset(CORNER7.keys()):
return [CORNER7[COLOR1],CORNER7[COLOR2],CORNER7[COLOR3]]
if frozenset([COLOR1,COLOR2,COLOR3])==frozenset(CORNER8.keys()):
return [CORNER8[COLOR1],CORNER8[COLOR2],CORNER8[COLOR3]]
def FINDMID(COLOR1,COLOR2):
MID1={CUBE[SFRONT][RTOP][CMID]:SFRONT,CUBE[STOP][RBOT][CMID]:STOP}
MID2={CUBE[SFRONT][RMID][CRIGHT]:SFRONT,CUBE[SRIGHT][RMID][CLEFT]:SRIGHT}
MID3={CUBE[SFRONT][RBOT][CMID]:SFRONT,CUBE[SUNDER][RTOP][CMID]:SUNDER}
MID4={CUBE[SFRONT][RMID][CLEFT]:SFRONT,CUBE[SLEFT][RMID][CRIGHT]:SLEFT}
MID5={CUBE[STOP][RMID][CRIGHT]:STOP,CUBE[SRIGHT][RTOP][CMID]:SRIGHT}
MID6={CUBE[STOP][RMID][CLEFT]:STOP,CUBE[SLEFT][RTOP][CMID]:SLEFT}
MID7={CUBE[SLEFT][RBOT][CMID]:SLEFT,CUBE[SUNDER][RMID][CLEFT]:SUNDER}
MID8={CUBE[SRIGHT][RBOT][CMID]:SRIGHT,CUBE[SUNDER][RMID][CRIGHT]:SUNDER}
MID9={CUBE[SBACK][RTOP][CMID]:SBACK,CUBE[STOP][RTOP][CMID]:STOP}
MID10={CUBE[SBACK][RMID][CRIGHT]:SBACK,CUBE[SLEFT][RMID][CLEFT]:SLEFT}
MID11={CUBE[SBACK][RBOT][CMID]:SBACK,CUBE[SUNDER][RBOT][CMID]:SUNDER}
MID12={CUBE[SBACK][RMID][CLEFT]:SBACK,CUBE[SRIGHT][RMID][CRIGHT]:SRIGHT}
if frozenset([COLOR1,COLOR2])==frozenset(MID1.keys()):
return [MID1[COLOR1],MID1[COLOR2]]
if frozenset([COLOR1,COLOR2])==frozenset(MID2.keys()):
return [MID2[COLOR1],MID2[COLOR2]]
if frozenset([COLOR1,COLOR2])==frozenset(MID3.keys()):
return [MID3[COLOR1],MID3[COLOR2]]
if frozenset([COLOR1,COLOR2])==frozenset(MID4.keys()):
return [MID4[COLOR1],MID4[COLOR2]]
if frozenset([COLOR1,COLOR2])==frozenset(MID5.keys()):
return [MID5[COLOR1],MID5[COLOR2]]
if frozenset([COLOR1,COLOR2])==frozenset(MID6.keys()):
return [MID6[COLOR1],MID6[COLOR2]]
if frozenset([COLOR1,COLOR2])==frozenset(MID7.keys()):
return [MID7[COLOR1],MID7[COLOR2]]
if frozenset([COLOR1,COLOR2])==frozenset(MID8.keys()):
return [MID8[COLOR1],MID8[COLOR2]]
if frozenset([COLOR1,COLOR2])==frozenset(MID9.keys()):
return [MID9[COLOR1],MID9[COLOR2]]
if frozenset([COLOR1,COLOR2])==frozenset(MID10.keys()):
return [MID10[COLOR1],MID10[COLOR2]]
if frozenset([COLOR1,COLOR2])==frozenset(MID11.keys()):
return [MID11[COLOR1],MID11[COLOR2]]
if frozenset([COLOR1,COLOR2])==frozenset(MID12.keys()):
return [MID12[COLOR1],MID12[COLOR2]]
def MIDMIDLAYER(COLOR1,COLOR2):
if (frozenset(FINDMID(COLOR1,COLOR2))==frozenset([STOP,SLEFT]))|(frozenset(FINDMID(COLOR1,COLOR2))==frozenset([STOP,SBACK]))|(frozenset(FINDMID(COLOR1,COLOR2))==frozenset([STOP,SRIGHT])):
return[TCLOCK]
if frozenset(FINDMID(COLOR1,COLOR2))==frozenset([SFRONT,SLEFT]):
return[TCOUNTERCLOCK,LCOUNTERCLOCK,TCLOCK,LCLOCK,TCLOCK,FCLOCK,TCOUNTERCLOCK,FCOUNTERCLOCK]
if frozenset(FINDMID(COLOR1,COLOR2))==frozenset([SBACK,SLEFT]):
return[TCOUNTERCLOCK,BCLOCK,TCLOCK,BCOUNTERCLOCK,TCLOCK,LCLOCK,TCOUNTERCLOCK,LCOUNTERCLOCK]
if frozenset(FINDMID(COLOR1,COLOR2))==frozenset([SFRONT,SRIGHT]):
return[TCLOCK,RCLOCK,TCOUNTERCLOCK,RCOUNTERCLOCK,TCOUNTERCLOCK,FCOUNTERCLOCK,TCLOCK,FCLOCK]
if frozenset(FINDMID(COLOR1,COLOR2))==frozenset([SBACK,SRIGHT]):
return[TCLOCK,BCOUNTERCLOCK,TCOUNTERCLOCK,BCLOCK,TCOUNTERCLOCK,RCOUNTERCLOCK,TCLOCK,RCLOCK]
if CUBE[SFRONT][RMID][CMID]!=CUBE[SFRONT][RTOP][CMID]:
return[TCOUNTERCLOCK,LCOUNTERCLOCK,TCLOCK,LCLOCK,TCLOCK,FCLOCK,TCOUNTERCLOCK,FCOUNTERCLOCK,TCOUNTERCLOCK,LCOUNTERCLOCK,TCLOCK,LCLOCK,TCLOCK,FCLOCK,TCOUNTERCLOCK,FCOUNTERCLOCK,TCLOCK,TCLOCK]
if CUBE[STOP][RBOT][CMID]==CUBE[SLEFT][RMID][CMID]:
return[TCOUNTERCLOCK,LCOUNTERCLOCK,TCLOCK,LCLOCK,TCLOCK,FCLOCK,TCOUNTERCLOCK,FCOUNTERCLOCK]
if CUBE[STOP][RBOT][CMID]==CUBE[SRIGHT][RMID][CMID]:
return[TCLOCK,RCLOCK,TCOUNTERCLOCK,RCOUNTERCLOCK,TCOUNTERCLOCK,FCOUNTERCLOCK,TCLOCK,FCLOCK]
return[]
def NEXTMOVE(STAGE):
if STAGE=='TOPLAYER':
if (CUBE[SRIGHT][RMID][CMID]==W)|(CUBE[SLEFT][RMID][CMID]==W):
CUBECLOCK()
return []
if CUBE[STOP][RMID][CMID]!=W:
CUBEUP()
return []
if (frozenset(FINDCORNER(W,E,B))==frozenset([STOP,SFRONT,SLEFT]))|(frozenset(FINDCORNER(W,E,B))==frozenset([STOP,SLEFT,SBACK]))|(frozenset(FINDCORNER(W,E,B))==frozenset([STOP,SBACK,SRIGHT])):
CUBERIGHT()
return []
if (FINDCORNER(W,E,B)==[SRIGHT,SFRONT,STOP])|(FINDCORNER(W,E,B)==[SFRONT,STOP,SRIGHT]):
return [RCOUNTERCLOCK,UCOUNTERCLOCK,RCLOCK,UCLOCK,UCLOCK,FCLOCK,UCOUNTERCLOCK,FCOUNTERCLOCK]
if (frozenset(FINDCORNER(W,E,B))==frozenset([SUNDER,SFRONT,SLEFT]))|(frozenset(FINDCORNER(W,E,B))==frozenset([SUNDER,SLEFT,SBACK]))|(frozenset(FINDCORNER(W,E,B))==frozenset([SUNDER,SBACK,SRIGHT]))|(frozenset(FINDCORNER(W,E,B))==frozenset([SUNDER,SFRONT,SRIGHT])):
return[RCLOCK,RCLOCK,LCLOCK,LCLOCK]
if frozenset(FINDCORNER(W,B,R))==frozenset([STOP,SLEFT,SBACK]):
return[BCOUNTERCLOCK,UCLOCK,UCLOCK,LCLOCK,UCOUNTERCLOCK,LCOUNTERCLOCK]
if frozenset(FINDCORNER(W,B,R))==frozenset([STOP,SBACK,SRIGHT]):
return[BCLOCK,UCLOCK,FCOUNTERCLOCK,UCLOCK,FCLOCK]
if (frozenset(FINDCORNER(W,B,R))==frozenset([SUNDER,SFRONT,SLEFT]))|(frozenset(FINDCORNER(W,B,R))==frozenset([SUNDER,SBACK,SLEFT])):
return[LCLOCK,LCLOCK]
if frozenset(FINDCORNER(W,B,R))==frozenset([SUNDER,SBACK,SRIGHT]):
return[BCLOCK,BCLOCK]
if frozenset(FINDCORNER(W,B,R))==frozenset([SUNDER,SFRONT,SRIGHT]):
return[UCOUNTERCLOCK,LCLOCK,LCLOCK]
if (FINDCORNER(W,B,R)==[SFRONT,SLEFT,STOP])|(FINDCORNER(W,B,R)==[SLEFT,STOP,SFRONT]):
return[LCLOCK,UCOUNTERCLOCK,LCOUNTERCLOCK,UCLOCK,LCLOCK,UCOUNTERCLOCK,LCOUNTERCLOCK]
if frozenset(FINDCORNER(W,R,G))==frozenset([STOP,SRIGHT,SBACK]):
return[BCLOCK,LCOUNTERCLOCK,UCLOCK,LCLOCK]
if (frozenset(FINDCORNER(W,R,G))==frozenset([SUNDER,SBACK,SRIGHT]))|(frozenset(FINDCORNER(W,R,G))==frozenset([SUNDER,SBACK,SLEFT])):
return[BCLOCK,BCLOCK]
if (frozenset(FINDCORNER(W,R,G))==frozenset([SUNDER,SFRONT,SRIGHT]))|(frozenset(FINDCORNER(W,R,G))==frozenset([SUNDER,SFRONT,SLEFT])):
return[UCLOCK,UCLOCK,BCLOCK,BCLOCK]
if (FINDCORNER(W,R,G)==[SBACK,STOP,SLEFT])|(FINDCORNER(W,R,G)==[SLEFT,SBACK,STOP]):
return[BCOUNTERCLOCK,UCOUNTERCLOCK,BCLOCK,UCLOCK,BCOUNTERCLOCK,UCOUNTERCLOCK,BCLOCK]
if (frozenset(FINDCORNER(W,G,E))==frozenset([SUNDER,SBACK,SLEFT]))|(frozenset(FINDCORNER(W,G,E))==frozenset([SUNDER,SFRONT,SLEFT]))|(frozenset(FINDCORNER(W,G,E))==frozenset([SUNDER,SFRONT,SRIGHT])):
return[UCLOCK]
if frozenset(FINDCORNER(W,G,E))==frozenset([SUNDER,SBACK,SRIGHT]):
return[UCOUNTERCLOCK,BCLOCK,UCLOCK,BCOUNTERCLOCK]
if (FINDCORNER(W,G,E)==[SBACK,SRIGHT,STOP])|(FINDCORNER(W,G,E)==[SRIGHT,STOP,SBACK]):
return[BCLOCK,UCLOCK,BCOUNTERCLOCK,UCOUNTERCLOCK,BCLOCK,UCLOCK,BCOUNTERCLOCK]
if frozenset(FINDMID(W,B))==frozenset([STOP,SRIGHT]):
CUBECLOCK()
return[FCOUNTERCLOCK,BCOUNTERCLOCK,UCOUNTERCLOCK,FCLOCK,BCLOCK,CUBECOUNTERCLOCK,UCOUNTERCLOCK,MIDCOUNTERCLOCK,UCLOCK,MIDCLOCK]
if frozenset(FINDMID(W,B))==frozenset([STOP,SBACK]):
return[MIDCLOCK,UCLOCK,MIDCOUNTERCLOCK,MIDCOUNTERCLOCK,UCLOCK,MIDCLOCK]
if frozenset(FINDMID(W,B))==frozenset([STOP,SLEFT]):
CUBECOUNTERCLOCK()
return[FCLOCK,BCLOCK,UCLOCK,FCOUNTERCLOCK,BCOUNTERCLOCK,CUBECLOCK,UCLOCK,MIDCOUNTERCLOCK,UCOUNTERCLOCK,MIDCLOCK]
if (frozenset(FINDMID(W,B))==frozenset([SFRONT,SRIGHT]))|(frozenset(FINDMID(W,B))==frozenset([SBACK,SRIGHT]))|(frozenset(FINDMID(W,B))==frozenset([SBACK,SLEFT])):
return[MIDRIGHT]
if frozenset(FINDMID(W,B))==frozenset([SFRONT,SLEFT]):
return[MIDLEFT,FCOUNTERCLOCK,MIDRIGHT,FCLOCK]
if (frozenset(FINDMID(W,B))==frozenset([SUNDER,SRIGHT]))|(frozenset(FINDMID(W,B))==frozenset([SUNDER,SBACK]))|(frozenset(FINDMID(W,B))==frozenset([SUNDER,SLEFT])):
return[UCLOCK]
if frozenset(FINDMID(W,B))==frozenset([SUNDER,SFRONT]):
return[UCLOCK,MIDCOUNTERCLOCK,UCOUNTERCLOCK,MIDCLOCK]
if FINDMID(W,B)==[SFRONT,STOP]:
return[MIDCOUNTERCLOCK,UCOUNTERCLOCK,MIDCLOCK,UCLOCK,MIDCOUNTERCLOCK,UCLOCK,UCLOCK,MIDCLOCK]
if frozenset(FINDMID(W,E))==frozenset([STOP,SBACK]):
return[MIDCLOCK,UCOUNTERCLOCK,MIDCOUNTERCLOCK,UCLOCK,CUBECLOCK,FCOUNTERCLOCK,BCOUNTERCLOCK,UCOUNTERCLOCK,FCLOCK,BCLOCK,CUBECOUNTERCLOCK]
if frozenset(FINDMID(W,E))==frozenset([STOP,SLEFT]):
CUBECOUNTERCLOCK()
return[FCLOCK,BCLOCK,UCLOCK,FCOUNTERCLOCK,BCOUNTERCLOCK,CUBECLOCK,CUBECLOCK,FCOUNTERCLOCK,BCOUNTERCLOCK,UCLOCK,FCLOCK,BCLOCK,CUBECOUNTERCLOCK]
if (frozenset(FINDMID(W,E))==frozenset([SFRONT,SLEFT]))|(frozenset(FINDMID(W,E))==frozenset([SBACK,SRIGHT]))|(frozenset(FINDMID(W,E))==frozenset([SBACK,SLEFT])):
return[MIDRIGHT]
if frozenset(FINDMID(W,E))==frozenset([SFRONT,SRIGHT]):
return[MIDLEFT,RCOUNTERCLOCK,MIDRIGHT,RCLOCK]
if (frozenset(FINDMID(W,E))==frozenset([SUNDER,SRIGHT]))|(frozenset(FINDMID(W,E))==frozenset([SUNDER,SBACK]))|(frozenset(FINDMID(W,E))==frozenset([SUNDER,SLEFT])):
return[UCLOCK]
if frozenset(FINDMID(W,E))==frozenset([SUNDER,SFRONT]):
CUBELEFT()
return[MIDCOUNTERCLOCK,UCLOCK,MIDCLOCK,CUBERIGHT]
if FINDMID(W,E)==[SRIGHT,STOP]:
CUBELEFT()
return[MIDCOUNTERCLOCK,UCOUNTERCLOCK,MIDCLOCK,UCLOCK,MIDCOUNTERCLOCK,UCLOCK,UCLOCK,MIDCLOCK,CUBERIGHT]
if frozenset(FINDMID(W,R))==frozenset([STOP,SBACK]):
return[MIDCLOCK,UCOUNTERCLOCK,MIDCOUNTERCLOCK]
if (frozenset(FINDMID(W,R))==frozenset([SFRONT,SRIGHT]))|(frozenset(FINDMID(W,R))==frozenset([SBACK,SRIGHT]))|(frozenset(FINDMID(W,R))==frozenset([SBACK,SLEFT])):
return[MIDRIGHT]
if frozenset(FINDMID(W,R))==frozenset([SFRONT,SLEFT]):
return[MIDRIGHT,LCLOCK,MIDLEFT,LCOUNTERCLOCK]
if (frozenset(FINDMID(W,R))==frozenset([SUNDER,SRIGHT]))|(frozenset(FINDMID(W,R))==frozenset([SUNDER,SBACK]))|(frozenset(FINDMID(W,R))==frozenset([SUNDER,SLEFT])):
return[UCLOCK]
if frozenset(FINDMID(W,R))==frozenset([SUNDER,SFRONT]):
CUBECOUNTERCLOCK()
return[FCLOCK,BCLOCK,UCOUNTERCLOCK,FCOUNTERCLOCK,BCOUNTERCLOCK,CUBECLOCK]
if FINDMID(W,R)==[SLEFT,STOP]:
CUBERIGHT()
return[MIDCOUNTERCLOCK,UCOUNTERCLOCK,MIDCLOCK,UCLOCK,MIDCOUNTERCLOCK,UCLOCK,UCLOCK,MIDCLOCK,CUBERIGHT]
if (frozenset(FINDMID(W,G))==frozenset([SFRONT,SRIGHT]))|(frozenset(FINDMID(W,G))==frozenset([SBACK,SRIGHT]))|(frozenset(FINDMID(W,G))==frozenset([SBACK,SLEFT])):
return[MIDRIGHT]
if frozenset(FINDMID(W,G))==frozenset([SFRONT,SLEFT]):
return[BCOUNTERCLOCK,MIDLEFT,BCLOCK]
if (frozenset(FINDMID(W,G))==frozenset([SUNDER,SRIGHT]))|(frozenset(FINDMID(W,G))==frozenset([SUNDER,SBACK]))|(frozenset(FINDMID(W,G))==frozenset([SUNDER,SFRONT])):
return[UCLOCK]
if frozenset(FINDMID(W,G))==frozenset([SUNDER,SLEFT]):
return[MIDCLOCK,UCOUNTERCLOCK,MIDCOUNTERCLOCK]
if FINDMID(W,G)==[SBACK,STOP]:
CUBERIGHT()
CUBERIGHT()
return[MIDCOUNTERCLOCK,UCOUNTERCLOCK,MIDCLOCK,UCLOCK,MIDCOUNTERCLOCK,UCLOCK,UCLOCK,MIDCLOCK,CUBERIGHT,CUBERIGHT]
return 'NEXTSTAGE'
if STAGE=='MID':
if CUBE[SFRONT][RMID][CMID]!=B:
return [MIDRIGHT]
if CUBE[SFRONT][RMID][CMID]==B:
CUBECLOCK()
CUBECLOCK()
return 'NEXTSTAGE'
if STAGE=='MIDLAYER1':
if FINDMID(B,R)!=[SFRONT,SRIGHT]:
return MIDMIDLAYER(B,R)
if FINDMID(B,E)!=[SFRONT,SLEFT]:
return MIDMIDLAYER(B,E)
CUBERIGHT()
CUBERIGHT()
return 'NEXTSTAGE'
if STAGE=='MIDLAYER2':
if FINDMID(G,E)!=[SFRONT,SRIGHT]:
return MIDMIDLAYER(G,E)
if FINDMID(G,R)!=[SFRONT,SLEFT]:
return MIDMIDLAYER(G,R)
return 'NEXTSTAGE'
if STAGE=='BOTTOMCROSS':
NUMBER=0
if CUBE[STOP][RMID][CLEFT]==Y:
NUMBER+=1
if CUBE[STOP][RTOP][CMID]==Y:
NUMBER+=1
if CUBE[STOP][RMID][CRIGHT]==Y:
NUMBER+=1
if CUBE[STOP][RBOT][CMID]==Y:
NUMBER+=1
if NUMBER==4:
return'NEXTSTAGE'
if (CUBE[STOP][RTOP][CMID]==Y)and(CUBE[STOP][RBOT][CMID]==Y):
return[LCLOCK,FCLOCK,TCLOCK,FCOUNTERCLOCK,TCOUNTERCLOCK,LCOUNTERCLOCK]
if (CUBE[STOP][RMID][CLEFT]==Y)and(CUBE[STOP][RMID][CRIGHT]==Y):
return[FCLOCK,RCLOCK,TCLOCK,RCOUNTERCLOCK,TCOUNTERCLOCK,FCOUNTERCLOCK]
if NUMBER==2:
if (CUBE[STOP][RMID][CLEFT]!=Y)or(CUBE[STOP][RTOP][CMID]!=Y):
return[TCLOCK]
if (CUBE[STOP][RMID][CLEFT]==Y)and(CUBE[STOP][RTOP][CMID]==Y):
return[FCLOCK,TCLOCK,RCLOCK,TCOUNTERCLOCK,RCOUNTERCLOCK,FCOUNTERCLOCK]
if NUMBER==0:
return[FCLOCK,RCLOCK,TCLOCK,RCOUNTERCLOCK,TCOUNTERCLOCK,FCOUNTERCLOCK]
if STAGE=='BOTTOMCORNERS1':
COUNT=0
if CUBE[STOP][RTOP][CLEFT]==Y:
COUNT+=1
if CUBE[STOP][RBOT][CLEFT]==Y:
COUNT+=1
if CUBE[STOP][RTOP][CRIGHT]==Y:
COUNT+=1
if CUBE[STOP][RBOT][CRIGHT]==Y:
COUNT+=1
if COUNT==4:
return'NEXTSTAGE'
if (COUNT==1)and(CUBE[STOP][RBOT][CLEFT]!=Y):
return[TCLOCK]
if (COUNT==1)and(CUBE[STOP][RBOT][CLEFT]==Y)and(CUBE[SFRONT][RTOP][CRIGHT]==Y):
return[RCLOCK,TCLOCK,RCOUNTERCLOCK,TCLOCK,RCLOCK,TCLOCK,TCLOCK,RCOUNTERCLOCK]
if (COUNT==1)and(CUBE[STOP][RBOT][CLEFT]==Y)and(CUBE[SRIGHT][RTOP][CLEFT]==Y):
return[TCLOCK,TCLOCK,RCLOCK,TCOUNTERCLOCK,TCOUNTERCLOCK,RCOUNTERCLOCK,TCOUNTERCLOCK,RCLOCK,TCOUNTERCLOCK,RCOUNTERCLOCK]
if (COUNT==2)and(CUBE[SFRONT][RTOP][CLEFT]!=Y):
return[TCLOCK]
if (COUNT==2)and(CUBE[SFRONT][RTOP][CLEFT]==Y):
return[RCLOCK,TCLOCK,RCOUNTERCLOCK,TCLOCK,RCLOCK,TCLOCK,TCLOCK,RCOUNTERCLOCK]
if COUNT==0:
return[RCLOCK,TCLOCK,RCOUNTERCLOCK,TCLOCK,RCLOCK,TCLOCK,TCLOCK,RCOUNTERCLOCK]
if STAGE=='BOTTOMCORNERS2':
if (CUBE[SFRONT][RTOP][CLEFT]==CUBE[SFRONT][RTOP][CRIGHT])and(CUBE[SLEFT][RTOP][CLEFT]==CUBE[SLEFT][RTOP][CRIGHT])and(CUBE[SRIGHT][RTOP][CLEFT]==CUBE[SRIGHT][RTOP][CRIGHT])and(CUBE[SBACK][RTOP][CLEFT]==CUBE[SBACK][RTOP][CRIGHT]):
return'NEXTSTAGE'
if (CUBE[SFRONT][RTOP][CLEFT]==CUBE[SFRONT][RTOP][CRIGHT])|(CUBE[SRIGHT][RTOP][CLEFT]==CUBE[SRIGHT][RTOP][CRIGHT])|(CUBE[SLEFT][RTOP][CLEFT]==CUBE[SLEFT][RTOP][CRIGHT]):
return[TCLOCK]
if CUBE[SBACK][RTOP][CLEFT]==CUBE[SBACK][RTOP][CRIGHT]:
return[RCOUNTERCLOCK,FCLOCK,RCOUNTERCLOCK,BCLOCK,BCLOCK,RCLOCK,FCOUNTERCLOCK,RCOUNTERCLOCK,BCLOCK,BCLOCK,RCLOCK,RCLOCK]
return[RCOUNTERCLOCK,FCLOCK,RCOUNTERCLOCK,BCLOCK,BCLOCK,RCLOCK,FCOUNTERCLOCK,RCOUNTERCLOCK,BCLOCK,BCLOCK,RCLOCK,RCLOCK]
if STAGE=='LASTSTAGE':
if CUBE[SFRONT][RTOP][CLEFT]!=CUBE[SFRONT][RMID][CMID]:
return[TCLOCK]
if (CUBE[SFRONT][RTOP][CMID]!=CUBE[SFRONT][RTOP][CLEFT])and(CUBE[SRIGHT][RTOP][CMID]!=CUBE[SRIGHT][RTOP][CLEFT])and(CUBE[SLEFT][RTOP][CMID]!=CUBE[SLEFT][RTOP][CLEFT])and(CUBE[SBACK][RTOP][CMID]!=CUBE[SBACK][RTOP][CLEFT]):
return[FCLOCK,FCLOCK,TCLOCK,LCLOCK,RCOUNTERCLOCK,FCLOCK,FCLOCK,LCOUNTERCLOCK,RCLOCK,TCLOCK,FCLOCK,FCLOCK]
if CUBE[SBACK][RTOP][CMID]!=CUBE[SBACK][RTOP][CLEFT]:
return[CUBERIGHT]
if CUBE[SFRONT][RTOP][CMID]==CUBE[SLEFT][RMID][CMID]:
return[FCLOCK,FCLOCK,TCLOCK,LCLOCK,RCOUNTERCLOCK,FCLOCK,FCLOCK,LCOUNTERCLOCK,RCLOCK,TCLOCK,FCLOCK,FCLOCK]
if CUBE[SFRONT][RTOP][CMID]==CUBE[SRIGHT][RMID][CMID]:
return[FCLOCK,FCLOCK,TCOUNTERCLOCK,LCLOCK,RCOUNTERCLOCK,FCLOCK,FCLOCK,LCOUNTERCLOCK,RCLOCK,TCOUNTERCLOCK,FCLOCK,FCLOCK]