-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscramble.py
More file actions
85 lines (66 loc) · 1.91 KB
/
scramble.py
File metadata and controls
85 lines (66 loc) · 1.91 KB
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
import random
modif = ["","'","2"]
def scramble_fm(s,len,mods=modif):
cb = ""
a = ""
res = ""
for _ in range(len):
while a == cb:
a = random.choice(s)
res += a + random.choice(mods) + " "
cb = a
return res
_s3 = ["R","L","U","D","F","B"]
scramble_3x3 = lambda l=20: scramble_fm(_s3,l)
_s2 = ["R","U","F"]
scramble_2x2 = lambda l=9: scramble_fm(_s2,l)
_s4 = ["R","L","U","D","F","B","Fw","Rw","Uw"]
scramble_4x4 = lambda l=45: scramble_fm(_s4,l)
scramble_5x5 = lambda l=60: scramble_fm(_s4,l)
_rcn = lambda: random.randrange(0,6)
_rcs = lambda: random.choice(["+","-"])
def _rpn(pins= ["UR","UL","DR","DL"],mods=['']):
np = random.randrange(0,len(pins))
po = ""
u = []
num = 0
while num <= np:
p = random.choice(pins)
if p in u:
pass
else:
po += p + random.choice(mods) +" "
num += 1
u.append(p)
return po
def scramble_clock():
pins = ["UR","DR","DL","UL","U","R","D","L","ALL","y2","U","R","D","L","ALL"]
res = ""
for pin in pins:
if pin == "y2":
res += pin + " "
continue
res += pin + str(_rcn()) + _rcs() + " "
return res + _rpn()
def scramble_megaminx():
res = ""
for _ in range(7):
res += scramble_fm(["R","D"],10,["--","++"])
if res.split(" ")[-2][-1] == "-":
res += "U'"
else:
res += "U"
res += "<br>"
return res
scramble_pyraminx = lambda l=9: scramble_fm(["R","L","U","B"],l,["","'"]) + _rpn(["r","b",'u','l'],["","\'"])
scramble_skewb = lambda l=9: scramble_fm(["R","L","U","B"],l,["","'"])
scramble_3bld = lambda l=20: scramble_fm(_s3,l,["","'"]) + _rpn(["R",'U','F'],["w","w\'","w2"])
scrambled = {"3x3":scramble_3x3,\
"2x2":scramble_2x2,\
"4x4":scramble_4x4,\
"5x5":scramble_5x5,\
"pyraminx":scramble_pyraminx,\
"skewb":scramble_skewb,\
"clock":scramble_clock,\
"3bld": scramble_3bld,\
"megaminx":scramble_megaminx}