-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathalgorithms.rb
79 lines (73 loc) · 1.63 KB
/
algorithms.rb
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
module RubiksCube
# Permutation and Orientation algorithms for two-cycle solution
module Algorithms
def self.reverse(algorithm)
algorithm.split.map do |move|
case modifier = move[-1]
when "'"
move[0]
when "2"
move
else
"#{move}'"
end
end.reverse.join ' '
end
module Permutation
Edge = "R U R' U' R' F R2 U' R' U' R U R' F'"
Corner = "U F R U' R' U' R U R' F' R U R' U' R' F R F' U'"
module Setup
Edge = {
0 => "M2 D L2",
2 => "M2 D' L2",
3 => "",
4 => "U' F U",
5 => "U' F' U",
6 => "U B U'",
7 => "U B' U'",
8 => "D' L2",
9 => "D2 L2",
10 => "D L2",
11 => "L2"
}
Corner = {
1 => "R2 D' R2",
2 => "",
3 => "B2 D' R2",
4 => "D R2",
5 => "R2",
6 => "D' R2",
7 => "D2 R2"
}
end
end
module Orientation
Edge = "M' U M' U M' U2 M U M U M U2"
Corner = "R' D R F D F' U' F D' F' R' D' R U"
module Setup
Edge = {
1 => "R B",
2 => "",
3 => "L' B'",
4 => "L2 B'",
5 => "R2 B",
6 => "B",
7 => "B'",
8 => "D2 B2",
9 => "D B2",
10 => "B2",
11 => "D' B2"
}
Corner = {
1 => "",
2 => "R'",
3 => "B2 R2",
4 => "D2 R2",
5 => "D R2",
6 => "R2",
7 => "D' R2"
}
end
end
end
end